Help with query/form with parameters

  • Thread starter Thread starter Megan via AccessMonster.com
  • Start date Start date
M

Megan via AccessMonster.com

Hi.

I am trying to send 2 parameters from a form in a VB module as a filter to a
form. But only one of the fields if populating. I don't know how much
information is needed on your side but here's the code - it's a click event.
[The Year is an unbound field on the form. It's in a combo box. It seems to
be presenting properly but I just can't seem to get it to populate in the
next form.]

glngCurrentCustID = Me![CustID]
glngCurrentYear = Me![Year]

gstrWhereOrder = "[Year] =" & "'" & glngCurrentYear & "'" & ";
[CustomerID] = " & glngCurrentCustID

'===========================
' this seems to display the appropriate filter
'===================================
MsgBox gstrWhereOrder

' New order for current customer...

DoCmd.openForm FormName:="qryInvoice1", WhereCondition:=gstrWhereOrder, _
OpenArgs:="New"
DoCmd.Close acForm, Me.Name


The qryInvoice1 form is based on a query that pulls in all records and I
thought would filter by the CustID and the Year. Year is a String and CustID
is an autonumber.
Can anyone give me an idea as to what I'm doing wrong?
I hope I'm explaining it clearly.
Thanks.
 
hi,
here is some test code i just wipped out. works.
try it.

Private Sub cmdgo_Click()
Dim glngCurrentCustID As String
Dim glngCurrentYear As String

glngCurrentCustID = Me![CustID]
glngCurrentYear = Me![Year1]

DoCmd.OpenForm "frmtest2", acNormal, , , acFormEdit
[Forms]![frmTest2]![tb1] = glngCurrentCustID
[Forms]![frmTest2]![tb2] = glngCurrentYear
DoCmd.Close acForm, Me.Name

End Sub
-----Original Message-----
Hi.

I am trying to send 2 parameters from a form in a VB module as a filter to a
form. But only one of the fields if populating. I don't know how much
information is needed on your side but here's the code - it's a click event.
[The Year is an unbound field on the form. It's in a combo box. It seems to
be presenting properly but I just can't seem to get it to populate in the
next form.]

glngCurrentCustID = Me![CustID]
glngCurrentYear = Me![Year]

gstrWhereOrder = "[Year] =" & "'" & glngCurrentYear & "'" & ";
[CustomerID] = " & glngCurrentCustID

'===========================
' this seems to display the appropriate filter
'===================================
MsgBox gstrWhereOrder

' New order for current customer...

DoCmd.openForm FormName:="qryInvoice1",
WhereCondition:=gstrWhereOrder, _
 
Back
Top