Hi,
When the user enters a new city I used an after update event on the text box and the statement INSERT INTO to add the newly entered city to tblUniqLoc . Here's the code:
Private Sub btnAddLocation_Click()
Me.txtGeoName.Visible = True
Me.txtGeoName.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub txtGeoName_AfterUpdate()
'These next lines are working if I remove everything in orange: It adds every records from tblGeoLoc. However, I just need the ID of the newly entered city in the text box. With the WHERE statement as below, Access prompts to add "0" lines to tblUniqLoc
DoCmd.RunSQL ("INSERT INTO tblUniqLoc(GeoLocID) SELECT ID FROM tblGeoLoc WHERE GeoName = ' & Me.txtGeoName & '")
Me.cboGeoLoc.SetFocus
End Sub
Private Sub cboGeoLoc_GotFocus()
DoCmd.RefreshRecord
Me.cboGeoLoc.Dropdown
End Sub
Anything an expert eye can spot here? Let me know if you need more details, any suggestions are very welcomed!
KB
When the user enters a new city I used an after update event on the text box and the statement INSERT INTO to add the newly entered city to tblUniqLoc . Here's the code:
Private Sub btnAddLocation_Click()
Me.txtGeoName.Visible = True
Me.txtGeoName.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub txtGeoName_AfterUpdate()
'These next lines are working if I remove everything in orange: It adds every records from tblGeoLoc. However, I just need the ID of the newly entered city in the text box. With the WHERE statement as below, Access prompts to add "0" lines to tblUniqLoc
DoCmd.RunSQL ("INSERT INTO tblUniqLoc(GeoLocID) SELECT ID FROM tblGeoLoc WHERE GeoName = ' & Me.txtGeoName & '")
Me.cboGeoLoc.SetFocus
End Sub
Private Sub cboGeoLoc_GotFocus()
DoCmd.RefreshRecord
Me.cboGeoLoc.Dropdown
End Sub
Anything an expert eye can spot here? Let me know if you need more details, any suggestions are very welcomed!
KB