INSERT INTO W/conditional target?

KingBroil

Registered User.
Local time
Today, 12:53
Joined
Oct 3, 2012
Messages
41
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
 
Thanks JD, I red the article and that gives me something to work on, much appreciated!
I'll post my results when I'll get some.

KB
 

Users who are viewing this thread

Back
Top Bottom