Results 1 to 5 of 5

Thread: Dialog Box

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

    Dialog Box

    Good Morning,

    I have a Parameter Query that is the recordsource for fProjInfo. When the user opens fProjInfo a Dialog box appears requesting the user to input a Project Number. Fine!!

    Now if the user wants to make another search, (this is the only way I knew how to do it...I'm sure there is something better....but) I put a control button on the form with the following code in the OnClick event:

    Function mQ12()
    On Error GoTo mQ12_Err

    DoCmd.Close acForm, "fProjInfo"
    DoCmd.OpenForm "fProjInfo", acNormal, "", "", , acNormal
    mQ12_Exit:
    Exit Function

    mQ12_Err:
    MsgBox Error$
    Resume mQ12_Exit

    End Function

    Fine!!!! Until the user inputs a number that doesn't exist...it only returns a blank form and the only thing that the user can do is Close the DB and re-open.

    If the user inputs a number that doesn't exist, I would like a dialog box to appear and notify the user "no such number, please re-enter a project code" and then run the query again. What do I need to do to accomplish this?

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

  2. #2
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Tennessee
    Posts
    194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dialog Box

    in one of my databases i have a separate form to key in the numbers then a second form shows the data i use this code to stop the blank screen you talked about

    Private Sub Form_Open(Cancel As Integer)
    Dim rst As DAO.Recordset
    On Error GoTo err
    Set rst = Me.RecordsetClone
    With rst
    rst.FindFirst "FORMS![OPENING FORM]![TEXTbox]'" = Me![data form textbox] & "'"

    If .NoMatch Then

    DoCmd.Close acForm, "OPENING FORM"
    GoTo something
    Else

    End If
    End With
    Set rst = Nothing
    DoCmd.Close acForm, "OPENING FORM"

    err:
    DoCmd.Close acForm, "data form"
    MsgBox "There is no such record"
    something:
    DoCmd.Close acForm, "OPENING FORM"
    End Sub
    HTH

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

    Re: Dialog Box

    Good Morning Jerry,

    Thanks for your reply....I know this is what I am looking for but I have a small problem and was hoping you could help me.

    I put the following code in the OnOpen event of fHello form (your opening form):

    Private Sub Form_Open(Cancel As Integer)
    Dim rst As DAO.Recordset
    On Error GoTo Err
    Set rst = Me.RecordsetClone
    With rst
    rst.FindFirst "Forms![fHello]![ProjNum]'" = Me![Project_Nbr] & "'"
    rst.FindFirst "Forms![fHello]![Task]'" = Me![Task_Code] & "'"

    If .NoMatch Then
    DoCmd.Close acForm, "fHello"
    GoTo something
    Else

    End If
    End With
    Set rst = Nothing
    DoCmd.Close acForm, "fHello"
    Err:
    DoCmd.Close acForm, "fLaborCost"
    MsgBox "Incorrect Project Number - Please re-enter"
    something:
    DoCmd.Close acForm, "fHello"
    'End Sub

    fHello has to text boxes, 1)Project Code and 2) Task No. in AfterUpdate event of Task No. I put this line of code:

    DoCmd.OpenForm "fLaborCost", acNormal, "", "", , acNormal

    fLaborCost is the form that holds cost involved on each project. (your data form)

    When I open fHello, the dialog box comes up informing me that I have entered a wrong project no. I don't have the opportunity to input data in the 2 text boxes. Any idea why?

    I know once I get past this it will do exactly as you said it would, but I am stumped.

    Please help!

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

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Tennessee
    Posts
    194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dialog Box

    try placing in the on open of the "fLaborCost" form
    not the hello form
    HTH

  5. #5
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dialog Box

    Hi Roberta -

    How about minimizing the chance for user error? Instead of letting her mistype a number, give her a lookup from which she can select a project (from a combobox, say).

Posting Permissions

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