Hi guys,
i have 3 forms that all have one button thats the same, so i thourght instead of having the code for the button on each form's button, i could have a module and call it when the button is pushed.
but i cant get it too work, here is my module's code ( module called SesTrkTblSav ):
the button code to run the module is as follows:
but instead of it running the code it just opens up the code in VB, what am i doing wrong.
best regards
i have 3 forms that all have one button thats the same, so i thourght instead of having the code for the button on each form's button, i could have a module and call it when the button is pushed.
but i cant get it too work, here is my module's code ( module called SesTrkTblSav ):
Code:
Option Compare Database
Public Sub SesTrkTblSav_Click()
' conenction and recordset object variables
Dim cn As Connection
Dim vbasuid As String
Dim vbpackref As String
Dim vbasstate As String
Dim vbasdate As String
vbasuid = asuid
vbpackref = Text6
vbasstate = asstate
vbasdate = Dateinputbox
' 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 "TBLPackHistory", cn, adOpenStatic, adLockPessimistic ' open it
.AddNew ' prepare to add a new record
.Fields("UserHistory") = vbasuid
.Fields("PackRef") = vbpackref
.Fields("StateHistory") = vbasstate
.Fields("DateHistory") = vbasdate
.Update ' update the table
.Close ' close the recordset connection
End With
Exit_SesTrkTblSav:
Exit Sub
End Sub
the button code to run the module is as follows:
Code:
Private Sub Command82_Click()
On Error GoTo Err_Command82_Click
DoCmd.OpenModule "SesTrkTblSav", "SesTrkTblSav_Click"
Exit_Command82_Click:
Exit Sub
Err_Command82_Click:
MsgBox Err.Description
Resume Exit_Command82_Click
End Sub
but instead of it running the code it just opens up the code in VB, what am i doing wrong.
best regards