Hi,
I have trouble understanding this:
I made a form that had as Record Source, a field from one of my database's table. Perhaps it was like that by default because I don't remember setting it myself. My form was properly functionning so far, but I decided change the Form's Record Source to "Null" so empty property field. Now the form doesn't seem to accept my DoCmd methods and returning errors when I run it. I red some documents about the Record Source of a Form, but I still can't get my head around it's use. What's the best way to make it work again?
Code:
Option Compare Database
Option Explicit
Private Sub btnAddLocation_Click()
Me.txtGeoName.Visible = True
Me.txtGeoName.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub cboGeoLoc_AfterUpdate()
'On Error Resume Next
' cmbSiteLoc.RowSource = 'SELECT DISTINCT SiteLocID ' & _
' "FROM tblUniqLoc " & _
' "WHERE GeoLoc = '" & cmbGeoLoc & "' " & _
' "ORDER BY PhyLoc"
End Sub
Private Sub cboGeoLoc_GotFocus()
DoCmd.RefreshRecord
Me.cboGeoLoc.Dropdown
End Sub
Private Sub txtGeoName_AfterUpdate()
Dim strSQL As String
DoCmd.RefreshRecord
strSQL = "INSERT INTO tblUniqLoc(GeoLocID)"
strSQL = strSQL & "SELECT tblGeoLoc.ID "
strSQL = strSQL & " WHERE GeoName ='" & Me.txtGeoName & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Me.cboGeoLoc.SetFocus
Me.txtGeoName.Visible = False
End Sub
Since I'm new to VBA and Access, nothing is obvious for me so I would gladly take any advices, thanks! (I have Access 2010)
KB
I have trouble understanding this:
I made a form that had as Record Source, a field from one of my database's table. Perhaps it was like that by default because I don't remember setting it myself. My form was properly functionning so far, but I decided change the Form's Record Source to "Null" so empty property field. Now the form doesn't seem to accept my DoCmd methods and returning errors when I run it. I red some documents about the Record Source of a Form, but I still can't get my head around it's use. What's the best way to make it work again?
Code:
Option Compare Database
Option Explicit
Private Sub btnAddLocation_Click()
Me.txtGeoName.Visible = True
Me.txtGeoName.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub cboGeoLoc_AfterUpdate()
'On Error Resume Next
' cmbSiteLoc.RowSource = 'SELECT DISTINCT SiteLocID ' & _
' "FROM tblUniqLoc " & _
' "WHERE GeoLoc = '" & cmbGeoLoc & "' " & _
' "ORDER BY PhyLoc"
End Sub
Private Sub cboGeoLoc_GotFocus()
DoCmd.RefreshRecord
Me.cboGeoLoc.Dropdown
End Sub
Private Sub txtGeoName_AfterUpdate()
Dim strSQL As String
DoCmd.RefreshRecord
strSQL = "INSERT INTO tblUniqLoc(GeoLocID)"
strSQL = strSQL & "SELECT tblGeoLoc.ID "
strSQL = strSQL & " WHERE GeoName ='" & Me.txtGeoName & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Me.cboGeoLoc.SetFocus
Me.txtGeoName.Visible = False
End Sub
Since I'm new to VBA and Access, nothing is obvious for me so I would gladly take any advices, thanks! (I have Access 2010)
KB