Results 1 to 4 of 4

Thread: doCmd.OpenForm

  1. #1
    Join Date
    Aug 2002
    Posts
    121

    Question Unanswered: doCmd.OpenForm

    Hello,
    I have 2 forms "FormA" and "FormB". The user enters search criteria in Form "A" and the results are displayed in form "B" using the to DoCmd below. However, when there are no records returned, Form "B" opens and it is completely gray without its controls. Can anyone suggest a way that I can throw a message box instead as an alternate to this blank form? The DoCmd is below....



    DoCmd.OpenForm "FormB", , , "username = currentuser() AND chart = Forms!Form1A.txt_Chart.Value

  2. #2
    Join Date
    Aug 2004
    Posts
    1
    If I understand what you are doing you just need to set a conditional if the query returns null (for safety I would do OR " " OR ""). Then just use the Do.cmd msgbox.

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Just for the heck of it...try this:

    Code:
    Dim StrgSQL As String
    StrgSQL = "[username] = '" & currentuser() & "' AND [chart] = '" & Forms!Form1A.txt_Chart.Value & "'"
     
    If DCount("[myTablesRecordID]", "myTableName", StrgSQL) <> 0 Then
    DoCmd.OpenForm "FormB", , , StrgSQL
    Else
    MsgBox"There are no records that meet your search criteria.", _
    vbInformation, "No Records Found"
    End If
    or something like it anyways...


  4. #4
    Join Date
    Aug 2002
    Posts
    121

    Talking

    Cyber,
    Thanks for the tip... It put me on the right track.. Thanks also to Bigmatt. Much appreciated!!!


Posting Permissions

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