Results 1 to 4 of 4

Thread: Open Form

  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open Form

    Good Morning,

    I have qProjectInfo which is the recordset for fProjectInfo. I have qMar/PM which is the recordset for fMar/PM. All have a field "ProjectNumber". I don't want to make fMar/PM a subform rather an option for the user to open the table if he/she chooses to, therefore I put the following in qMar/PM:

    forms![fProjectInfo]![ProjectNumber]

    When the user clicks the button, qMar/PM retrieves only the information for that ProjectNumber from fProjectInfo and opens fMar/PM to that project number in fMar/PM and displays that pn history.

    However, I also want the user to have the option of opening the entire fMar/PM if he/she chooses to, without creating another query or form. I thought I could simply put the following code in the OnClick event of a button, but it doesn't work. Does someone have any suggestions please.

    Private Sub Command51_Click()
    DoCmd.OpenForm "fMar/PM", acNormal
    DoCmd.FindRecord "Forms!fProjectInfo!ProjectNumber", , True, , True
    'DoCmd.GoToRecord , , acCurrent
    End Sub

    Thanks in advance.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Open Form

    Hi Roberta,
    I think you need to change your code so it reads:
    DoCmd.findrecord Forms!fProjectInfo!ProjectNumber, , True, , True, acall
    with no inverted commas around the Forms!fProjectInfo!ProjectNumber and acAll at the end (the default is to look in the current field and there isn't one if you've just clicked on a command button)
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Open Form

    If your form is based on a query with a parameter, you can't force the form to open without that parameter. You would be better advised to remove the parameter from the query and pass a where condition to the form in the DoCmd.OpenForm call to filter the contents. That way, you could open the form either way. It would also save you having to find the record you're looking for once you open the form.
    Charlotte

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Form

    Rory,

    Your suggestion worked perfectly....thanks for the advice.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •