G
Guest
Access 2000. I keep getting a type mismatch on "NewCertNum" with this code
shown below. "NewCertNum" should be text. I tried a sugggestion a week or
so ago but it didn't work. Any ideas? Thanks for any help, Randy.
Private Sub Form_AfterUpdate()
Dim stDocName As String
Dim strSQL As String
Dim NewCertNum As String
Dim CertBeg As String
Dim CertEnd As String
Dim knt As Integer
Dim Msg As String
Dim Response As String
DoCmd.SetWarnings False
If [EndCertNolbl] = 0 Then
stDocName = "SingleCertAppendQuery"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else
'get the beginning and ending Cert numbers
CertBeg = Me.BeginCertNolbl
CertEnd = Me.EndCertNolbl
cnt = 0
' Define message.
Msg = "BegCert # = " & CertBeg & vbCrLf & "EndCert # = " & CertEnd &
vbCrLf
Msg = Msg & vbCrLf & "Insert Certifcates?"
Style = vbQuestion + vbYesNo + vbDefaultButton1 ' Define buttons.
' Display message.
Response = MsgBox(Msg, Style)
If Response = vbYes Then ' User chose Yes.
For NewCertNum = CertBeg To CertEnd
' create the SQL statement to insert the new records
strSQL = "INSERT INTO CheckedOutCertsAllNumbers (
CertNo,Inspector,TypeOfCert,DateCheckedOut )"
strSQL = strSQL & " Values ( '"
strSQL = strSQL & " NewCertNum & '"
strSQL = strSQL &
[Forms]![frmCheckedOutCertificates]![cboInspector] & ", '"
strSQL = strSQL & "#" &
[Forms]![frmCheckedOutCertificates]![DateCheckedOutlbl] & "#,''' "
strSQL = strSQL &
[Forms]![frmCheckedOutCertificates]![cboTypeofCert] & "'); "
' now do it
CurrentDb.Execute strSQL
cnt = cnt + 1
Next
DoCmd.SetWarnings True
End If
End If
End Sub
shown below. "NewCertNum" should be text. I tried a sugggestion a week or
so ago but it didn't work. Any ideas? Thanks for any help, Randy.
Private Sub Form_AfterUpdate()
Dim stDocName As String
Dim strSQL As String
Dim NewCertNum As String
Dim CertBeg As String
Dim CertEnd As String
Dim knt As Integer
Dim Msg As String
Dim Response As String
DoCmd.SetWarnings False
If [EndCertNolbl] = 0 Then
stDocName = "SingleCertAppendQuery"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else
'get the beginning and ending Cert numbers
CertBeg = Me.BeginCertNolbl
CertEnd = Me.EndCertNolbl
cnt = 0
' Define message.
Msg = "BegCert # = " & CertBeg & vbCrLf & "EndCert # = " & CertEnd &
vbCrLf
Msg = Msg & vbCrLf & "Insert Certifcates?"
Style = vbQuestion + vbYesNo + vbDefaultButton1 ' Define buttons.
' Display message.
Response = MsgBox(Msg, Style)
If Response = vbYes Then ' User chose Yes.
For NewCertNum = CertBeg To CertEnd
' create the SQL statement to insert the new records
strSQL = "INSERT INTO CheckedOutCertsAllNumbers (
CertNo,Inspector,TypeOfCert,DateCheckedOut )"
strSQL = strSQL & " Values ( '"
strSQL = strSQL & " NewCertNum & '"
strSQL = strSQL &
[Forms]![frmCheckedOutCertificates]![cboInspector] & ", '"
strSQL = strSQL & "#" &
[Forms]![frmCheckedOutCertificates]![DateCheckedOutlbl] & "#,''' "
strSQL = strSQL &
[Forms]![frmCheckedOutCertificates]![cboTypeofCert] & "'); "
' now do it
CurrentDb.Execute strSQL
cnt = cnt + 1
Next
DoCmd.SetWarnings True
End If
End If
End Sub