Private Sub cmdAdd_Click()
'Dim gCountryID As Integer
'Dim gStateID As Integer
'Dim gCityName As String
Dim n As Integer
Dim nName As String
On Error GoTo cmdAdd_Click_Error
gCountryID = Nz([Forms]![frmAddLocation]![CountryRecID])
gStateID = Nz([Forms]![frmAddLocation]![StateRecID])
gCityName = Nz([Forms]![frmAddLocation]![CityName])
n = DCount("*", "tblCity", "[CityName] Like '*" & gCityName & "*' " & _
"AND [CountryRecID] = " & gCountryID & " " & _
"AND [StateRecID] = " & gStateID & "")
If n = 0 Then
DoCmd.RunSQL _
("INSERT INTO tblCity ( CountryRecID, StateRecID, CityName, TaxInclusive, Top5000, DateCreated, Modifiedby ) " _
& "VALUES ( '" & gCountryID & "', '" & gStateID & "', '" & _
gCityName & "', " & gTaxIncl & ", " & gTop & ", Date(), '" & _
GetgUserID() & "' )")
Else
[b]' nName = gCityName & ", " & [Forms]![frmAddLocation]![StateRecID].Column(1) & ", " & [Forms]![frmAddLocation]![CountryRecID].Column(1)
' Debug.Print nName
Select Case MsgBox("Records Found & ", " & gCityName & , vbYesNo Or vbExclamation Or vbDefaultButton1, ")[/b]
Case vbYes
Case vbNo
End Select
End If
On Error GoTo 0
Exit Sub
cmdAdd_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAdd_Click of VBA Document Form_frmAddLocation"
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE