hi me again,
i have created a function that updates the content of a table, but at the moment to get the current values i have to use dlookup and then add what is required to the current value.
is there a better way of doing this?
here is my code:
best regards
i have created a function that updates the content of a table, but at the moment to get the current values i have to use dlookup and then add what is required to the current value.
is there a better way of doing this?
here is my code:
Code:
Call poststatsupd(2, fOSUserName, Date, "test", DLookup("[Pack_posted]", "tbl_personal_stats", "[User_Stats_an] = 2") + 1, DLookup("[Trans_posted]", "tbl_personal_stats", "[User_Stats_an] = 2") + Text39, DLookup("[geo_req]", "tbl_personal_stats", "[User_Stats_an] = 2") + IIf([Geo] = -1, 1, 0), DLookup("[dr4_in_pack]", "tbl_personal_stats", "[User_Stats_an] = 2") + IIf([Dr4inp] = -1, 1, 0))
Code:
Public Function poststatsupd(vbarecord As String, VBAUser_ID As String, VBAdate As String, VBArole As String, VBAPack_posted As String, VBATrans_posted As String, VBAgeo_req As String, VBAdr4_in_pack As String)
' open a connection to the connection object
Set Cn = CurrentProject.Connection
' initialise the recordset object
Set rs = New ADODB.Recordset
' using the recordset object
With rs
.Open "tbl_personal_stats", Cn, adOpenStatic, adLockOptimistic ' open it
.Find "User_Stats_an ='" & vbarecord & "'"
.Fields("User_ID") = VBAUser_ID
.Fields("date") = VBAdate
.Fields("role") = VBArole
.Fields("Pack_posted") = VBAPack_posted
.Fields("Trans_posted") = VBATrans_posted
.Fields("geo_req") = VBAgeo_req
.Fields("dr4_in_pack") = VBAdr4_in_pack
.Update ' update the table
.Close ' close the recordset connection
End With
End Function
best regards