Filter ID to new form in unbound control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box on a form for the user to select a Project Number. After
selected, they can open a new form that would filter that Project Number and
show that record in the new form. However, my code isn't working. It just
pulls up the first record in that table. Can someone help me with the codes?
Here is what I have for the button to open the new form:

DoCmd.OpenForm "frmApplication", acNormal
Dim holdID As Long
holdID = Me.cboChildren
DoCmd.GoToControl "ProjectNumber"
DoCmd.FindRecord holdID, , True, , True, , True
End Sub
 
The form you open, it's bound to a table.
Does the field ProjectNumber exist in this table?

When you use the where condition , the filter need to be on an existing field.

--
Good Luck
BS"D


Flipper said:
Also, my combo box is unbound and also, my "ProjectNumber" on frmApplication
is unbound. Is this going to mess anything up?

Ofer Cohen said:
Use the Where Condition in the OpenForm command line

Dim MyCondition As String
MyCondition = "[ProjectNumber] = " & Me.cboChildren
DoCmd.OpenForm "frmApplication", acNormal , , MyCondition

Note: The ProjectNumber need to be the name of the field in the table
--
Good Luck
BS"D


Flipper said:
I have a combo box on a form for the user to select a Project Number. After
selected, they can open a new form that would filter that Project Number and
show that record in the new form. However, my code isn't working. It just
pulls up the first record in that table. Can someone help me with the codes?
Here is what I have for the button to open the new form:

DoCmd.OpenForm "frmApplication", acNormal
Dim holdID As Long
holdID = Me.cboChildren
DoCmd.GoToControl "ProjectNumber"
DoCmd.FindRecord holdID, , True, , True, , True
End Sub
 
Use the Where Condition in the OpenForm command line

Dim MyCondition As String
MyCondition = "[ProjectNumber] = " & Me.cboChildren
DoCmd.OpenForm "frmApplication", acNormal , , MyCondition

Note: The ProjectNumber need to be the name of the field in the table
 
Ok, I tried that and now it is asking for the "ProjectNumber" for a parameter
value. I wonder if it is because of the order I do things. I first go to the
combo box and select the project number that I want the form to open to.
Then I click on a command button to open the form with that project number
record selected. So, do I also need something for the combo box after update
event? Thanks.



Ofer Cohen said:
Use the Where Condition in the OpenForm command line

Dim MyCondition As String
MyCondition = "[ProjectNumber] = " & Me.cboChildren
DoCmd.OpenForm "frmApplication", acNormal , , MyCondition

Note: The ProjectNumber need to be the name of the field in the table
--
Good Luck
BS"D


Flipper said:
I have a combo box on a form for the user to select a Project Number. After
selected, they can open a new form that would filter that Project Number and
show that record in the new form. However, my code isn't working. It just
pulls up the first record in that table. Can someone help me with the codes?
Here is what I have for the button to open the new form:

DoCmd.OpenForm "frmApplication", acNormal
Dim holdID As Long
holdID = Me.cboChildren
DoCmd.GoToControl "ProjectNumber"
DoCmd.FindRecord holdID, , True, , True, , True
End Sub
 
Back
Top