Results 1 to 5 of 5

Thread: Form Open (A2K)

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

    Form Open (A2K)

    Good Afternoon,

    I have the following code that should work, but it doesn't.

    I have a form (frmCPTCodes), the undelying qry is qryCPTCodes. In the qry I have : forms!frmCPTCodes!txtCPT for the for the criteria of "ProcCode":

    Dim strMsg As String, strInput As String
    DoCmd.Restore

    'I don't want the form visible unless the criteria is met
    Forms!frmCPTCodes.Visible = False

    'User inputs CPT Code and that code should be assigned to the text box
    strInput = InputBox("CPT Code?")
    Me.txtProcCode = strInput

    'If the Code DOESN'T exist the user gets the following Message and choices
    strMsg = "That CPT Code doesn't Exist, Search Again?"

    If MsgBox(strMsg, vbYesNo, "Error!") = vbYes Then
    Beep
    strInput = InputBox("Enter CPT Code")
    Forms!frmCPTCodes.Visible = True

    Else
    DoCmd.Close acForm, "frmCPTCodes"
    Exit Sub
    End If
    Exit Sub

    What am I missing? I have a button from another form, that when clicked should open frmCPTCodes; the criteria of the qry is based on the text box of frmCPTCodes which is provided by an Input box in the OnOpen event of the form. If the criteria is met then the form should open to that record, however, if the criteria isn't met, a MsgBox informs the user that the CPT Code doesn't exist, would they like to do another search.

    The problem is, is nothing appears after the criteria is met (I've used numbers which I know for a fact exist) therefore, the MsgBox continues to appear......

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

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Open (A2K)

    'User inputs CPT Code and that code should be assigned to the text box
    strInput = InputBox("CPT Code?")
    Me.txtProcCode = strInput

    'If the Code DOESN'T exist the user gets the following Message and choices
    strMsg = "That CPT Code doesn't Exist, Search Again?"

    If MsgBox(strMsg, vbYesNo, "Error!") = vbYes Then

    You ask for a CPT Code, you put it in a texbox and you say that it doesn't exist. You don't do any search. Is there some code you haven't copy ?
    Francois

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

    Re: Form Open (A2K)

    Francois,

    The answer is NO....posted the entire code.....and am lost as to why it don't work.

    Any suggestions?

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

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

    Re: Form Open (A2K)

    It doesn't work because you have no mechanism for checking to see whether the code exists. You jump stright to the messagebox without any kind of check in between. How are you trying to determine that the code does or doesn't exist? You need a DLookup or something else to allow you to check. If the code does exist, then you have to requery the hidden form and make it visible. It won't automatically show the right records anyhow unless you nudge it to requery or close and reopen it. I don't really see much point in hiding and showing it when you are trying to change the criteria for its underlying query. You might as well close and reopen.
    Charlotte

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Open (A2K)

    Can you post a stripped version of your db so we can see what you are trying to do ?
    Francois

Posting Permissions

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