Good Day All.
I have a form with a button, a textbox1 and some other textboxes
Basically when the button is pressed I want the event to cause a table to open with only records of the value in the textbox1. I then want to add a new record using values from the textboxes on the form to the new record fields
This is the code I have tried but it is not working. Can anyone assist?
Option Compare Database
Private Sub Command26_Click()
Dim curDatabase As DAO.Database
Dim rs As DAO.Recordset
Set curDatabase = CurrentDb
Set rs = CurrentDb.OpenRecordset("Select * from [tblSignin] ")
If Not rs.RecordCount = 0 Then
rs.MoveLast
rs.MoveFirst
End If
rs.AddNew
rs.Fields(1) = Now()
rs.Fields(2) = Form_frmSignin.txtUser
rs.Fields(3) = Now()
rs.Fields(4) = Now()
rs.Fields(8) = Now()
rs.Fields(9) = "AutoSave"
If rs.RecordCount Mod 2 = 1 Then
rs.Fields(6) = "IN"
Else: rs.Fields(6) = "OUT"
End If
rs.Update
Set curDatabase = Nothing
Set rs = Nothing
End Sub
I have a form with a button, a textbox1 and some other textboxes
Basically when the button is pressed I want the event to cause a table to open with only records of the value in the textbox1. I then want to add a new record using values from the textboxes on the form to the new record fields
This is the code I have tried but it is not working. Can anyone assist?
Option Compare Database
Private Sub Command26_Click()
Dim curDatabase As DAO.Database
Dim rs As DAO.Recordset
Set curDatabase = CurrentDb
Set rs = CurrentDb.OpenRecordset("Select * from [tblSignin] ")
If Not rs.RecordCount = 0 Then
rs.MoveLast
rs.MoveFirst
End If
rs.AddNew
rs.Fields(1) = Now()
rs.Fields(2) = Form_frmSignin.txtUser
rs.Fields(3) = Now()
rs.Fields(4) = Now()
rs.Fields(8) = Now()
rs.Fields(9) = "AutoSave"
If rs.RecordCount Mod 2 = 1 Then
rs.Fields(6) = "IN"
Else: rs.Fields(6) = "OUT"
End If
rs.Update
Set curDatabase = Nothing
Set rs = Nothing
End Sub