I am just testing if a record exists in and sql server
CertificateNr. All I am trying to do is get the value of a column of a table in sql server from Access vba to test its value in my if. I just do know know how to do this.
1.how to run the below select and put the value in the variable strCertificate number
2. how to run the strCheck(the variable with T-sql select string in it)? use a 'DoCmd.runsql strCheck'
or a execute or what.
3. is using Exit Funtion good practice to not let the code complete after tossing and error to the use that they cannot complete the action , Notify IT support?
Thanks! Adam
'Check to see that there is not an Endorsement Transaction Record into table: "EndorsementTransactions"
strCheck = "SELECT CertificateNr " & _
"FROM dbo.EndorsementTransactions " & _
"WHERE strCertificateNr = " & CertificateNr.Value & " AS strCertificateNr"
DoCmd.RunSQL strCheck
If strCertificateNr <> "" Then
MsgBox "Cannot Endorse! Please notify IT / Development" & vbCrLf & vbCrLf & _
strCertificateNr & vbCrLf & _
vbOKOnly & vbExclamation, cstrApplicationName
Exit Function
End If
CertificateNr. All I am trying to do is get the value of a column of a table in sql server from Access vba to test its value in my if. I just do know know how to do this.
1.how to run the below select and put the value in the variable strCertificate number
2. how to run the strCheck(the variable with T-sql select string in it)? use a 'DoCmd.runsql strCheck'
or a execute or what.
3. is using Exit Funtion good practice to not let the code complete after tossing and error to the use that they cannot complete the action , Notify IT support?
Thanks! Adam
'Check to see that there is not an Endorsement Transaction Record into table: "EndorsementTransactions"
strCheck = "SELECT CertificateNr " & _
"FROM dbo.EndorsementTransactions " & _
"WHERE strCertificateNr = " & CertificateNr.Value & " AS strCertificateNr"
DoCmd.RunSQL strCheck
If strCertificateNr <> "" Then
MsgBox "Cannot Endorse! Please notify IT / Development" & vbCrLf & vbCrLf & _
strCertificateNr & vbCrLf & _
vbOKOnly & vbExclamation, cstrApplicationName
Exit Function
End If