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

DoCmd Open Form Where Condition 1

Status
Not open for further replies.

08211987

Programmer
Apr 20, 2012
187
US
Can the where condition in the Open Form argument contain a field that is defined as Text in the table used in the form or does it have to be a field that is defined as Number?

I have 2 different forms that have subforms and on the subform one of the fields is a hyperlink with an on click event the performs the below code. The code that is used for the field that is defined as Number in the table design opens the form with the contents of that row. But the code that is used for the field that is defined as Text in the table displays "Enter Parameter Value" then displays the value of the text field I selected. Once I enter the same value in the prompt field and click ok it opens the correct form for that field. A quick note, both integers below in code are defined as String.

Code for Text field:
Private Sub KI_ID_Nbr_Click()
IntID = Me.KI_ID_Nbr 'IntID defined as Global KI_ID As String, Me.KI_ID_Nbr defined as Text in table
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.OpenForm "form_Initiatives_and_Items", , , "KI_ID_Nbr = " & IntID, acFormEdit End Sub

Code for Numeric field:
Private Sub Item_Nbr_Click()
hold_Item_Nbr = Me.Item_Nbr 'hold_Item_Nbr defined as Global hold_Item_Nbr As String (but Me.Item_Nbr table value is Number and it works!)
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.OpenForm "form_Initiative_Item_Detail", , , "Item_Nbr = " & hold_Item_Nbr, acFormEdit
End Sub

Appreciate any assistance!
Thanks.
 
Since "KI_ID_Nbr defined as Text in table", you can try:
[tt]
DoCmd.OpenForm "form_Initiatives_and_Items", , , "KI_ID_Nbr = [blue]'[/blue]" & IntID [blue]& "'"[/blue], acFormEdit
[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
You are a genius - thanks so much!! I was lost....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top