Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arguments are of the wrong type or are in conflict with one another.

Status
Not open for further replies.

livvie

Programmer
Apr 20, 2004
91
IE
Hi Guys
Anybody know what is causing this error "Arguments are of the wrong type or are in conflict with one another." or how can I trace it. It occurs when I add a new record. The data is added but this error is also displayed.
Cheers
 
I dont have HTH in my References ? I do use ADO as in is Access Project I am working in and I use ADODB.Recordser and ADODB.Connection. I am not using any DAO references as far as I know.
 
HTH is Hope That Helps!

Declare all your objects explicitly i.e. ADODB.Recordset rather than Recordset. If that doesn't help, post your code.

Craig
 
Gee I feel thick now.
Here is the code anyway.
Private Sub cmdFinished_Click()
'Change the focus back to the main form and hide the data entry form
Forms!frmDrawingscomplete!cboCust.SetFocus
Me.Visible = False
'Make visible and Requery the viewing forms
Forms!frmDrawingscomplete!fsubDrawRev1.Form.Requery
Forms!frmDrawingscomplete!fsubDrawRev1.Form.Visible = True
Forms!frmDrawingscomplete!fsubDraw.Form.Requery
Forms!frmDrawingscomplete!fsubDraw.Form.Visible = True

Dim sql1 As String
Dim str As String
Dim strSQLRestore As String
Dim cnn As Connection
Dim rstDrawings As ADODB.Recordset
Dim strsql1 As String
Dim MyCustPartid As Variant
Dim MyNewCustPartid As String
Dim blnRecordAddred As Boolean


On Error GoTo Err_cmdSave_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

'Open a connection
Set cnn = New ADODB.Connection

str = "Provider=SQLOLEDB;Data Source=SBS;" & _
"Initial Catalog=DrawingsDemoSQL;User Id=SQLACCESS;Password=caragh*2004;"
cnn.Open str

'Open table tblDrawRev to update .
Set rstDrawings = New ADODB.Recordset
strsql1 = "tblDrawings"
rstDrawings.Open strsql, cnn, adOpenKeyset, adLockOptimistic, adCmdTable

rstDrawings.MoveLast
rstDrawings!CustPartid = MyCustPartid

rstDrawings.Update

'Close the recordset
rstDrawings.Close
Set rstDrawings = Nothing

'Close the connection
cnn.Close
Set cnn = Nothing
Exit Sub

ErrorHandler:
'Clean Up

If Not rstCustPart Is Nothing Then
If rstCustPart.State = adStateOpen Then rstCustPart.Close
End If
Set rstDraw = Nothing


If Not cnn Is Nothing Then
If cnn.State = adStateOpen Then cnn.Close
End If
Set cnn = Nothing


If Err <> 0 Then
MsgBox Err.Source & "--->" & Err.Description, , "Error"
End If


Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub
 
rstDrawings.Open strsql, cnn, adOpenKeyset, adLockOptimistic, adCmdTable

is likely to be the source of your problem. I can't see strsql declared anywhere. You declare strsql1 and strSQLRestore but not strsql.

Craig
 
I don't see where in the code you are attempting to add a new record, but I do see where you're attemption to update the last record in the table.

rstDrawings!CustPartid = MyCustPartid

MyCustPartid is declared as a variant, so it may not be a compatible type to rstDrawings!CustPartid. Further, I don't see where MyCustPartid is assigned an actual value, which may mean you trying to assign a Null value to a field type which cannot be null.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Yippie de do dah youve fixed it. Made both changes and it's sorted. See it really pays to have someone else look at your code (i'm on my own here)
Thanks guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top