I have VBA code that inserts a new record in two tables from one form.
When I press the submit button, it creates the two records in the separate tables as I wanted, however it creates a blank record with only one field ("Station") filled out in the table tblUsers.
Code:
Private Sub CloseUser_Click()
Dim DBBS As Database
Dim rs As DAO.Recordset
Dim rss As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT FullName, HashID, Password, UserSecurity, Station, Status FROM tblUsers")
With rs
.AddNew
!FullName = Me.UserName
!HashID = Me.HashID
!Password = Me.Password
!UserSecurity = Me.UserSecurity
!Station = Me.Station
!Status = Me.Status
.Update
End With
rs.Close
Set rs = Nothing
Set rss = CurrentDb.OpenRecordset("SELECT PLocation, Shift, Type, Station FROM tblLocations")
With rss
.AddNew
!PLocation = Me.HashID
!Shift = Me.Shift
!Type = Me.Type
!Station = Me.Station
.Update
End With
rss.Close
Set rss = Nothing
DoCmd.Close
End Sub
I have a feeling it might have something to do with both tables having that station value but that is all I could think of.. any help would be greatly appreciated.
Thanks as always