1
ห้อง MS Access / : ต้องการบันทึก Report เป็น PDF ซึ่งชื่อไฟล์PDF เป็นชื่อบุคคลในRecoedนั้นอัตโนมัติ
« เมื่อ: 01 มี.ค. 66 , 09:01:06 »
ขอบคุณมากครับ
โพสต์นี้ได้รับคำขอบคุณจาก: laemthong
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strDate As String
Dim strUser As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT * FROM MyTable WHERE ((Not (MyTable.DateR) Is Null));", dbOpenDynaset)
If Not rst.BOF And Not rst.EOF Then
rst.MoveFirst
End If
Do Until rst.EOF
strDate = rst!DateR
strUser = rst!UserR
rst.Edit
rst!SEQrec = DLookup("RunSEQ", "Q2", "cstr(DateR) = '" & strDate & "' and cstr(UserR) = '" & strUser & "'")
rst.Update
rst.MoveNext
Loop
rst.Close: Set rst = Nothing
db.Close: Set db = Nothing
Public Function MakeTableWithConvertToRow2(ByVal sMainTable As String, ByVal sTempTable As String)
'On Error Resume Next
Dim RS_IN As DAO.Recordset
Dim RS_OUT As DAO.Recordset
Dim ColName As Integer
Set RS_IN = CurrentDb.OpenRecordset("Select" & "* from " & sMainTable & "")
'Set RS_OUT = CurrentDb.OpenRecordset("Select" & "* from " & sTempTable & "")
Set RS_OUT = CurrentDb.OpenRecordset(sTempTable, dbOpenTable)
Do While Not RS_IN.EOF
RS_OUT.Index = "PrimaryKey"
RS_OUT.Seek "=", RS_IN(0).Value
For ColName = 0 To RS_OUT.Fields.Count - 1
If RS_OUT.NoMatch Then
RS_OUT.AddNew
Else
RS_OUT.Edit
End If
If RS_IN(1).Value = RS_OUT(ColName).Name Then
RS_OUT(0).Value = RS_IN(0).Value
RS_OUT(RS_OUT(ColName).Name).Value = RS_IN(2).Value
RS_OUT.Update
End If
Next
RS_IN.MoveNext
Loop
RS_IN.Close
RS_OUT.Close
Set RS_IN = Nothing
Set RS_OUT = Nothing
End Function
Public Function MakeTableWithConvertToRow(ByVal sMainTable As String, ByVal sTempTable As String)
Dim RS_IN As Recordset
Dim RS_OUT As Recordset
Dim ColName As Integer
Set RS_IN = CurrentDb.OpenRecordset("Select" & "* from " & sMainTable & "")
Set RS_OUT = CurrentDb.OpenRecordset("Select" & "* from " & sTempTable & "")
Do While Not RS_IN.EOF
For ColName = 1 To RS_IN.Fields.Count - 1
RS_OUT.AddNew
RS_OUT("ID") = RS_IN("ID")
RS_OUT("Subject") = RS_IN(ColName).Name
RS_OUT("G") = RS_IN(ColName).Value
RS_OUT.Update
Next
RS_IN.MoveNext
Loop
RS_IN.Close
RS_OUT.Close
Set RS_IN = Nothing
Set RS_OUT = Nothing
End Function