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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type mismatch

Status
Not open for further replies.

site

Programmer
Oct 23, 2001
44
AT
Hello,

Hope someone help me out.

When I open the form I got error:

"compiler error: User-defined type not defined." then I added reference "microsoft DAO 3.6 object library". the error is gone.

But when I click the form's buttom, I got error:
"Run-time error 13, Type mismatch"

The following are my codes:

Private Sub Form_Open(Cancel As Integer)
Dim db As Database, rst As Recordset, dt As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("Temp_Cal_30")'(mismatch here)
dt = CDate(rst.Fields("30Date"))
If rst.RecordCount > 0 Then
rst.MoveFirst
If dt < Now() Then
AppendDatesMo
End If
ElseIf rst.RecordCount = 0 Then
AppendDatesMo
Else
End If

End Sub


Thank you very much for your kind help.
Jing
 
try adding this too

Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database, rst As DAO.Recordset, dt As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset(&quot;Temp_Cal_30&quot;)'(mismatch here)
dt = CDate(rst.Fields(&quot;30Date&quot;))
If rst.RecordCount > 0 Then
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Also look at ADO
this is the newest way to connect to anything

you have to check &quot;... ADO object 2.5 ...&quot; in &quot;Tools&quot; &quot;References&quot;

But when you understand ADO, you can use it anywhere including VBScript (ASP Active Server Pages) as in WEB sites !!!!

here is a start
-----------------
Dim Conn2 As ADODB.Connection
Dim Rs1 As ADODB.Recordset

Dim SQLCode As String

Set Conn2 = CurrentProject.Connection ' <<<<Note same as CurrentDb

Set Rs1 = New ADODB.Recordset

SQLCode = &quot;SELECT * FROM [STOCK CODE LOOKUP] WHERE STOCK_CODE = '&quot; & Me![Part Number] & &quot;';&quot;
Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic

' Note: do normal rs1! or rs1. stuff from now on
'like Rs1!fieldname
' Rs1.addnew

' close it this way
Set rs1 = nothing
Set Conn2 = nothing


DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Hi, DougP,

I follow you info., the error is gone, but I got the another error&quot; Too few paremeters, Expected5&quot;. I don't know why?

Thanks again.
Jing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top