klwu
Brainy!!
- Local time
- Today, 21:55
- Joined
- Sep 13, 2004
- Messages
- 47
Hi, I have some problems with my codes here. The system keeps saying that my variables not defined. How do I solve this problem? Thanks
Code:
Private Sub cmdCreateNew_Click()
On Error GoTo Err_cmdCreateNew_Click
'1.Check if cmbCompanyID is selected
'2.Generate a unique numer for this Company ID
'3.Insert a row in M_Ip table
'4.Go to IPAddress form
Dim sSql As String, refIx As Long, dbs As Database
'task 1 begins here--------
If IsNull(cmbCompanyID) Or cmbCompanyID = "" Then
MsgBox "Please select the Company ID"
GoTo Exit_cmdCreateNew_Click
End If
'task 2 begins here--------
refIx = NextVal(cmbCompanyID)
'task 3 begins here-------
sSql = "INSERT INTO M_Ip (RefNo, CompanyID) VALUES" & _
"(" & refIx & ", '" & [B]txtCompanyID [/B] & "');" [COLOR=Red]<- Error here[/COLOR]
'task 4 begins here------
DoCmd.OpenForm "IPAddress", acNormal, , "RefNo =" & refIx
DoCmd.SetWarnings True
cmbCompanyID = ""
'MsgBox sSql
DoCmd.SetWarnings False
DoCmd.RunSQL sSql
Exit_cmdCreateNew_Click:
Exit Sub
Err_cmdCreateNew_Click:
MsgBox Err.Description
Resume Exit_cmdCreateNew_Click
End Sub