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

Type Mismatch error

Status
Not open for further replies.

Fonzie

MIS
Feb 16, 2001
74
0
0
CA
What I am trying to do is for the given part number in a subform, a query will run to add all quantities in all workorders for that part number. I have the code entered below, but keep getting a 'Type Mismatch' error. I have no idea where to go from here.

Private Sub Quantity_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
Dim rst As Recordset
Dim db As Database
Dim strsql As String
strsql = "SELECT Sum(WorkorderDetails.Quantity) AS temp FROM WorkorderDetails WHERE PartNumber = '" & Me!PartNumber & "';"
Set db = CurrentDb
Set rst = db.OpenRecordset(strsql)
rst.MoveFirst
If rst!temp > 1 Then
MsgBox ("More that One")
Else
End If
rst.Close
End Sub
 
Add a test for RecordCount on the recordset. It may be that the query is returning no records.

If rst.recordcount>0 Then
' Query returned no rows
Else
rst.MoveFirst
If rst!temp>0 Then
.
.
.
Terry

The reason why worry kills more people than work is that more people worry than work. - Robert Frost
 
I tried entering your code, but still coming up with 'Type Mismatch'.
 
Found problem in different post. DAO library needed to have higher priority that ADO.
 
Set rst = db.OpenRecordset(sSQL, dbOpenDynaset)
If Not rst.BOF Then rst.MoveLast
i = rst.RecordCount To object or not to object
That is the question
Alast poor varible I new you well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top