Hi comunity,
I have this piece of code. I am looking for a way to INSERT INTO tblUniqLoc(SiteLoc), but for the records in tblUniqLoc(GeoLocID) that matches the user input in the same form's previous control: (" & Me.cboGeoLoc & ") Not on a new line as it does now.
Private Sub txtSiteName_AfterUpdate()
Dim strSQL As String
DoCmd.RefreshRecord
strSQL = "INSERT INTO tblUniqLoc(SiteLocID)"
strSQL = strSQL & "SELECT ID FROM tblSiteLoc "
strSQL = strSQL & " WHERE SiteName ='" & Me.txtSiteName & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Me.cboSiteLoc.SetFocus
Me.txtSiteName.Visible = False
End Sub
I have tried with an append query, but could not manage to have it work right. Is there a way to modify this code to have it work the way I need?
So now I see 2 options: Modify this code or work on an append query.
Any suggestions would be much appreciated. Ask if you need more details.
KB
I have this piece of code. I am looking for a way to INSERT INTO tblUniqLoc(SiteLoc), but for the records in tblUniqLoc(GeoLocID) that matches the user input in the same form's previous control: (" & Me.cboGeoLoc & ") Not on a new line as it does now.
Private Sub txtSiteName_AfterUpdate()
Dim strSQL As String
DoCmd.RefreshRecord
strSQL = "INSERT INTO tblUniqLoc(SiteLocID)"
strSQL = strSQL & "SELECT ID FROM tblSiteLoc "
strSQL = strSQL & " WHERE SiteName ='" & Me.txtSiteName & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Me.cboSiteLoc.SetFocus
Me.txtSiteName.Visible = False
End Sub
I have tried with an append query, but could not manage to have it work right. Is there a way to modify this code to have it work the way I need?
So now I see 2 options: Modify this code or work on an append query.
Any suggestions would be much appreciated. Ask if you need more details.
KB