This is the code that I have in the program, but when I run it, run-time error 3061 too few parameters. expected 3. tb1 is a query. but when I replace query for table this code never move it the first record.
I have problems with this code.
First : tb1 is a query and when I run it send this error run-time error 3061 too few parameters. expected 3.
Second: When I use Table on Tb1 the program work, but never skip to the next record.
I try to work with query table because I need to relationship two tablet this is focus on this code to try to resolve it.
Thank you so much.
Thank you
Dim db As Database, tb1, tb2 As Recordset
Dim esvar As Variant
Dim mLabattInv, mLabattInvDate, LabattInvoiceNum, mDescription, mBItemNum, mVINum As Long
Set db = DBEngine.Workspaces(0).Databases(0)
Set tb1 = db.OpenRecordset("LabattOutUSAQuery") 'Query
Set tb2 = db.OpenRecordset("CEInfo") 'Table
Date1 = [Forms]![MainMenu]![Da1]
Date2 = [Forms]![MainMenu]![da2]
With tb1
tb1.MoveFirst
Do While Not tb1.EOF
If tb1!InvoiceDate >= Date1 Or tb!InvoiceDate <= Date2 Then
If CountryofOrigin <> "USA" Then
mLabattInvDate = InvoiceDate
mDescription = Description
mBItemNum = BItemNum
mVINum = ItemNum
MsgBox (Invoicenum + " " + ItemNum + " " + Description)
With tb2
.Index = "InvoiceNuml"
esvar2 = .Bookmark
.Seek "=", mLabattInv, ItemNum
If .NoMatch Then
'MsgBox (LabattInvoiceNum + " & " + CStr([InvoiceDate]) + " doesn't exist this is add")
.AddNew
!LabattInv = Me.Invoice__
!CEDate = Me.Invoice_Date
!LabattInvDate = Me.Invoice_Date
!BidNum = Me.BItemNum
!WeekNum = Format(Me.Invoice_Date, "WW")
!VINum = Me.Item__
!CEName = "Laredo ISD"
!FoodProduct = Me.Description
!CountryOrigin = Me.CountryofOrigin
!Ruta = "\\WIN-U3C12L3PKMM\Account\USDADoc\BuyAmerican\Labatt Invoice " & Me.Item__ & ".pdf"
!CEID = "01122"
!IndicatesoriginNoUS = True
!Nosourcecanprovide = True
!NoThereisnosubstitutedomesticfood = True
!Nocostdifference = True
!WhatdocumentationhasCE = "Region One Food Items July 1, 2022-June 30,2023 RFP 23-AGENCY-000106"
Else
.Edit
!LabattInv = mLabattInv
!CEDate = mLabattInvDate
!LabattInvDate = mLabattInvDate
!CEName = "Laredo ISD"
!CEID = "01122"
!IndicatesoriginNoUS = True
!Nosourcecanprovide = True
!NoThereisnosubstitutedomesticfood = True
!Nocostdifference = True
!WhatdocumentationhasCE = "Region One Food Items July 1, 2022-June 30,2023 RFP 23-AGENCY-000106"
End If
End With
.Update
Else
End If
Else
End If
tb1.MoveNext
Loop
End With