G
Guest
I'm trying to delete records from a table using the rst.Delete and I can't
seem to get the rst.Find to work below is the code. and below that is the
error message i'm getting.
Public Sub codDeleteEmployee()
Dim rst As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim sqlString As String
Dim strCompanyName As String, strCustEmpFirstName As String,
strCustEmpLastName As String
'Dim strCustEmpPhone As Variant, strExtNum As Variant,
memOptionalPhoneNumbers As Variant
'Dim strCustEmpEmail As Variant, memCustEmpMemo As Variant, strEmpIDNum As
Variant
strCompanyName =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCompanyName
strCustEmpFirstName =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpFirstName
'strCustEmpLastName =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpLastName
'strCustEmpPhone =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpPhone
'strExtNum =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strExtNum
'memOptionalPhoneNumbers =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!memOptionalPhoneNumbers
'strCustEmpEmail =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpEmail
'memCustEmpMemo =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!memCustEmpMemo
'0101 Code below deletes data
Set cnn = CurrentProject.Connection
rst.Open "tblCompaniesEmployees", cnn, adOpenStatic, adLockOptimistic,
adCmdTableDirect
sqlString = "[strCompanyName] = '" & strCompanyName & "' AND " &
"[strCustEmpFirstName] = '" & strCustEmpFirstName & "'" & ""
' The line below returns this ([strCompanyName] = 'Contech - Aub' AND
[strCustEmpFirstName] = 'Carlos') minus perenthasis
Debug.Print sqlString
rst.MoveFirst
rst.Find sqlString
MsgBox rst!strCompanyName
End Sub
I like to use msgboxs and Debug.Prints for debuging so I know what data im
using so that is why those lines probably don't make a lot of good sense to
you pro's.
The error message i get is Run-time error '3001':
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
When I select Debug it goes to the rst.Find sqlString
Any reasons why or tips?
seem to get the rst.Find to work below is the code. and below that is the
error message i'm getting.
Public Sub codDeleteEmployee()
Dim rst As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim sqlString As String
Dim strCompanyName As String, strCustEmpFirstName As String,
strCustEmpLastName As String
'Dim strCustEmpPhone As Variant, strExtNum As Variant,
memOptionalPhoneNumbers As Variant
'Dim strCustEmpEmail As Variant, memCustEmpMemo As Variant, strEmpIDNum As
Variant
strCompanyName =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCompanyName
strCustEmpFirstName =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpFirstName
'strCustEmpLastName =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpLastName
'strCustEmpPhone =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpPhone
'strExtNum =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strExtNum
'memOptionalPhoneNumbers =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!memOptionalPhoneNumbers
'strCustEmpEmail =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!strCustEmpEmail
'memCustEmpMemo =
Forms!frmMainPhonListForm092203!frmCompanyEmployeePhoneCard110403.Form.Controls!memCustEmpMemo
'0101 Code below deletes data
Set cnn = CurrentProject.Connection
rst.Open "tblCompaniesEmployees", cnn, adOpenStatic, adLockOptimistic,
adCmdTableDirect
sqlString = "[strCompanyName] = '" & strCompanyName & "' AND " &
"[strCustEmpFirstName] = '" & strCustEmpFirstName & "'" & ""
' The line below returns this ([strCompanyName] = 'Contech - Aub' AND
[strCustEmpFirstName] = 'Carlos') minus perenthasis
Debug.Print sqlString
rst.MoveFirst
rst.Find sqlString
MsgBox rst!strCompanyName
End Sub
I like to use msgboxs and Debug.Prints for debuging so I know what data im
using so that is why those lines probably don't make a lot of good sense to
you pro's.
The error message i get is Run-time error '3001':
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
When I select Debug it goes to the rst.Find sqlString
Any reasons why or tips?