run time error 3615 - type mismatch

Kully121

New Member
Joined
Sep 21, 2004
Messages
44
Hi,

I am running a procedure from a macro under a "Run Code" , Procedure

'AppendDays'("Monday")

However when i run it it comes up with an error message ("3615 Type Mismatch")

It highlights the following line in my AppendDays Procedure;


Set rs = db.OpenRecordset(strData)

Code as follows - anyone please help? Cheers

Function AppendDays(strDay As String)

Dim strData As String
strData = "SELECT [B - " & strDay & " Production Plan]." & strDay & ", [B - " & strDay & " Production Plan].PRODUCT, [A - Date Entry].Cycle, [B - " & strDay & " Production Plan].INGEST, [B - " & strDay & " Production Plan].EDIT, [B - " & strDay & " Production Plan].MDATA, [B - " & strDay & " Production Plan].[V/OVER], [B - " & strDay & " Production Plan].DELIV, [B - " & strDay & " Production Plan].TOTAL, [B - " & strDay & " Production Plan].OPERATOR, [B - " & strDay & " Production Plan].[OP CATGRY], [B - " & strDay & " Production Plan].[CAT ID], [B - " & strDay & " Production Plan].FOLDER, [B - " & strDay & " Production Plan].SOURCE1, [B - " & strDay & " Production Plan].SOURCE2, [B - " & strDay & " Production Plan].SOURCE3, [B - " & strDay & " Production Plan].SOURCE4, [B - " & strDay & " Production Plan].MON, [A - Date Entry].Date FROM [A - Date Entry] INNER JOIN [B - " & strDay & " Production Plan] ON [A - Date Entry].Day = [B - " & strDay & " Production Plan]." & strDay & ";"

Dim db As Database
Dim rs As Recordset
Dim rs2 As Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset(strData)
Set rs2 = db.OpenRecordset("SELECT * FROM [Z - Final Production Plan]")

Dim i As Integer

Do While rs.EOF = False

i = rs.Fields(Left(strDay, 3))

For x = 1 To i
rs2.AddNew
rs2.Fields("Day Plan") = rs.Fields("Day Plan")
rs2.Fields("Product ID") = rs.Fields("Product ID")
rs2.Fields("Date") = rs.Fields("Date")
rs2.Fields("Cycle") = rs.Fields("Cycle")
rs2.Fields("Day") = rs.Fields("Day")
rs2.Fields("Ingest") = rs.Fields("Ingest")
rs2.Fields("Edit") = rs.Fields("Edit")
rs2.Fields("MData") = rs.Fields("MData")
rs2.Fields("V/OVER") = rs.Fields("V/OVER")
rs2.Fields("DELIV") = rs.Fields("DELIV")
rs2.Fields("TOTAL") = rs.Fields("TOTAL")
rs2.Fields("OPERATOR") = rs.Fields("OPERATOR")
rs2.Fields("OP CATGRY") = rs.Fields("OP CATGRY")
rs2.Fields("CAT ID") = rs.Fields("CAT ID")
rs2.Fields("FOLDER") = rs.Fields("FOLDER")
rs2.Fields("SOURCE1") = rs.Fields("SOURCE1")
rs2.Fields("SOURCE2") = rs.Fields("SOURCE2")
rs2.Fields("SOURCE3") = rs.Fields("SOURCE3")
rs2.Fields("SOURCE4") = rs.Fields("SOURCE4")
rs2.Fields("Monday") = rs.Fields("Monday")
rs2.Fields("Tuesday") = rs.Fields("Tuesday")
rs2.Fields("Wednesday") = rs.Fields("Wednesday")
rs2.Fields("Thursday") = rs.Fields("Thursday")
rs2.Fields("Friday") = rs.Fields("Friday")
rs2.Fields("Saturday") = rs.Fields("Saturday")
rs2.Fields("Sunday") = rs.Fields("Sunday")
rs2.Fields("Notes") = rs.Fields("Notes")
rs2.Fields("Qty") = rs.Fields("Qty")
rs2.Update
Next
rs.MoveNext
Loop

db.Close
rs.Close



'Debug.Print strData

End Function
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Is there a mismatch in dates? It seems you have fields for dates and then you have text fields as "Monday," "Tuesday,"..

If you try to match 3/29/06 with "Wednesday," it will give you a type mismatch

Also, Qty is not included in strData, is that ok?
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top