Results 1 to 6 of 6
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    MsgBox Reference Field from Table on unbound form

    Hi, I have been trying to get this to work with no luck.

    I have an unbound form with an unbound text box named SrchMedID with serveral buttons. Within my code I have a msgbox to ask a question; within the msgbox I would like to show the date populated in my field named "SuppressDate" if there is a date entered (not all records have a date). Here is the latest code I have come up with (the code in red below is where I am having the issue):

    Private Sub btnsrch_Click()
    Dim MedID As String
    Dim SuppressDate As Date
    ' Get Value from Medicaid_ID textbox on the Form:
    Me.btnsrch.SetFocus
    Me.SrchMed_ID.SetFocus
    MedID = Me.SrchMed_ID.Text

    Dim Msg, Style, Title, MyString
    Dim Response As Integer

    If IsNull(DLookup("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'")) Then


    DoCmd.OpenForm "RA_Tracking", , , , acFormAdd
    Me.SrchMed_ID = ""

    Else

    If (DCount("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'" & _
    "And Not Nz([SuppressDate])")) Then

    DoCmd.OpenForm "RA_Tracking", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
    Me.SrchMed_ID = ""

    Else

    Response = MsgBox("Is the RA a Refund with a $0.00 balance with an RA Date prior to " & Format([SuppressDate], "mm/dd/yyyy") & " (date will be set-up tp auto populate later, click 'No' and compare RA Date to Suppress Date)" & vbNewLine & vbNewLine & "If RA Date is prior to the Suppress Date = Recycle; otherwise log RA and give to Lisa", vbYesNo) 'added 12/11/2014

    If Response = vbYes Then 'added 12/112014

    MsgBox ("Do not log RA's for this Medicaid ID:" & (Chr(13)) & (Chr(13)) & " " & [SrchMed_ID] & (Chr(13)) & (Chr(13)) & "Recycle this providers RA's")
    Me.SrchMed_ID = ""



    ElseIf Response = vbNo Then

    DoCmd.OpenForm "RA_Tracking", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
    Me.SrchMed_ID = ""


    End If
    End If
    End If
    End Sub

    The message I receive with this code is:

    Is the RA a Refund with a $0.00 balance with an RA Date prior to 12/30/1899 (date will be set-up tp auto populate later, click 'No' and compare RA Date to Suppress Date)

    If RA Date is prior to the Suppress Date = Recycle, otherwise log RA and give to Lisa

    12/30/1899 is not the date in the field on my table for the record. I have also tried:

    1. Format("SuppressDate", "mm/dd/yyyy")
    2. [SuppressDate]
    3. (SuppressDate)


    any suggestions to get the msgbox to display the date field named "SuppressDate" from my table named "Returned_Mail" on an unbound form?
    Thanks

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    first sanity check things by not doing the Format the first time around...

    also instead of: & [SuppressDate] &

    try: # [SuppressDate] #

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Actually the Format was the last thing I tried...

    Your suggestion: #[SuppressDate]# gives me a the following message:

    Is the RA a Refund with a $0.00 balance with an RA Date prior to #[SuppressDate]# (date will be set-up tp auto populate later, click 'No' and compare RA Date to Suppress Date)

    If RA Date is prior to the Suppress Date = Recycle, otherwise log RA and give to Lisa

    Since my form is unbound and the "SuppressDate" field is not a part of the form, do I need to reference the table from where the field "SuppressDate" is maintained?
    Thanks.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You need to tell Access where or what #[SuppressDate]# is.

    I find your code difficult to read.

    I have a free routine called SmartIndenter and I ran your code though it to get this reformatting
    Code:
    Private Sub btnsrch_Click()
        Dim MedID As String
        Dim SuppressDate As Date
        ' Get Value from Medicaid_ID textbox on the Form:
        Me.btnsrch.SetFocus
        Me.SrchMed_ID.SetFocus
        MedID = Me.SrchMed_ID.text
    
        Dim Msg, Style, Title, MyString   '<-----these are variants by default
        Dim Response As Integer
    
        If IsNull(DLookup("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'")) Then
            DoCmd.OpenForm "RA_Tracking", , , , acFormAdd
            Me.SrchMed_ID = ""
    
        Else
    
            If (DCount("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'" & _
                                                         "And Not Nz([SuppressDate])")) Then 'what do you expect from NZ
                                                                                                              'maybe you meant IsNull()
    
                DoCmd.OpenForm "RA_Tracking", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
                Me.SrchMed_ID = ""
    
            Else
    
                Response = MsgBox("Is the RA a Refund with a $0.00 balance with an RA Date prior to " & Format([SuppressDate], "mm/dd/yyyy") & " (date will be set-up tp auto populate later, click 'No' and compare RA Date to Suppress Date)" & vbNewLine & vbNewLine & "If RA Date is prior to the Suppress Date = Recycle; otherwise log RA and give to Lisa", vbYesNo)    'added 12/11/2014
    
                If Response = vbYes Then    'added 12/112014
    
                    MsgBox ("Do not log RA's for this Medicaid ID:" & (Chr(13)) & (Chr(13)) & " " & [SrchMed_ID] & (Chr(13)) & (Chr(13)) & "Recycle this providers RA's")
                    Me.SrchMed_ID = ""
    
    
    
                ElseIf Response = vbNo Then
    
                    DoCmd.OpenForm "RA_Tracking", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
                    Me.SrchMed_ID = ""
    
    
                End If
            End If
        End If
    End Sub

    Where is SuppressDate??

    Do you have a clear concise description of what this code is trying to accomplish?
    I recommend you test incrementally to get piece to work, and then progressively add more details/complexity.
    Good luck with your project.

  5. #5
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Ok, I made some changes to my code and it seems to be working now. Here is the new code:

    Dim MedID As String
    Dim SuppressDate As Date
    ' Get Value from Medicaid_ID textbox on the Form:
    Me.btnsrch.SetFocus
    Me.SrchMed_ID.SetFocus
    MedID = Me.SrchMed_ID.Text

    If IsNull(DLookup("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'")) Then
    DoCmd.OpenForm "RA_Tracking", , , , acFormAdd
    Me.SrchMed_ID = ""

    Else
    If (DCount("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'" & _
    "And Not Nz([SuppressDate])")) Then

    DoCmd.OpenForm "RA_Tracking", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
    Me.SrchMed_ID = ""

    Else

    Dim Msg, Style, Title, MyString
    Dim Response As Integer
    Msg = (Chr(10)) & " Does the RA contain a 'Refunds from Provider' with a 'Refund Total' of $0.00 for 'Suspense Remaining' with an RA Date prior to" & vbNewLine & vbNewLine & " " & (DLookup("[SuppressDate]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'")) & "? " & vbNewLine & vbNewLine & "Select:" & vbNewLine & "Yes = Recycle RA" & vbNewLine & "No = Input RA" & vbNewLine & "Cancel - Cancel Inquiry"
    Style = vbYesNoCancel + vbInformation + vbDefaultButton0
    Title = "Answer Question"

    Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then

    MsgBox ("Do not log RA's for this Medicaid ID:" & (Chr(13)) & (Chr(13)) & " " & [SrchMed_ID] & (Chr(13)) & (Chr(13)) & "Recycle this providers RA's")
    Me.SrchMed_ID = ""
    Else
    If Response = vbNo Then
    DoCmd.OpenForm "RA_Tracking", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
    Me.SrchMed_ID = ""
    If Response = vbCancel Then
    MyString = "Cancel"
    DoCmd.CancelEvent
    Me.SrchMed_ID = ""
    Else
    Response = Cancel
    Me.SrchMed_ID = ""
    Close


    End If
    End If
    End If
    End If
    End If
    End Sub

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I still recommend you get the free SmartIndenter, and also MZTools for VBA also free.
    They are excellent, free utilities.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-11-2014, 12:57 PM
  2. Replies: 5
    Last Post: 02-12-2014, 11:52 PM
  3. Replies: 16
    Last Post: 03-26-2013, 07:11 PM
  4. Replies: 6
    Last Post: 08-16-2012, 04:15 PM
  5. Replies: 8
    Last Post: 05-26-2011, 07:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums