INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

DoCmd Open Form Where Condition

DoCmd Open Form Where Condition

(OP)
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.

RE: DoCmd Open Form Where Condition

Since "KI_ID_Nbr defined as Text in table", you can try:

DoCmd.OpenForm "form_Initiatives_and_Items", , , "KI_ID_Nbr = '" & IntID & "'", acFormEdit

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.

RE: DoCmd Open Form Where Condition

(OP)
You are a genius - thanks so much!! I was lost....

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close