Results 1 to 3 of 3
  1. #1
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46

    Question Dcount results from a form object combobox

    Hi all, Im new to this fourm!

    I am running the following subroutine and it does not seem to be returning the proper results and maybe you guys can see something I dont..

    Private Sub Command8_Click()
    'verifys if there is data for the selected log date combobox - na 11_19_13
    Dim Lresults As Long
    Lresults = DCount("ID", "tblTIMESHEET", "LOG_DATE=" & Combo2)
    If Lresults = 0 Then
    MsgBox ("Please select another date" & vbCrLf & "No data for selected date!")
    Else
    Me.Visible = False
    DoCmd.OpenForm ("frmTIMESHEET_EDITS")
    End If
    End Sub

    What im tryin to do:
    I'm using the dcount function check to see if there is an already existing record with the selected combobox date, if so, then proceed to open form event, if not, then deisplay msgbox for user to selected another date.

    Whats Happening:
    It continues to tell me there are no results even though I do have records in my [LOG_DATE] with the selected date in the combobox.

    Any help is appericiated.. I think I may just be overlooking something simple.

    Thanks experts!



    Regards,
    Naeem~

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Lresults = DCount("ID", "tblTIMESHEET", "LOG_DATE=#" & Combo2 & "#")

  3. #3
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Great thank you! I see now that since it is a date field, it would require the # for date dateypes.

    Thanks again! glad to join this forum!

    Private Sub Command8_Click()
    'verifys if there is data for the selected log date - na 11_19_13
    Dim Lresults As Long
    Lresults = DCount("ID", "tblTIMESHEET", "LOG_DATE=#" & Combo2 & "#")
    If Lresults = 0 Then
    MsgBox ("Please select another date" & vbCrLf & "No data for selected date!")
    Else
    Me.Visible = False
    DoCmd.OpenForm ("frmTIMESHEET_EDITS")
    End If
    End Sub

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

Similar Threads

  1. No Results on Requery for Combobox RowSource
    By dccjr in forum Programming
    Replies: 3
    Last Post: 05-10-2013, 06:08 PM
  2. Replies: 4
    Last Post: 08-06-2012, 07:05 PM
  3. Save Combobox results to Table
    By Kinder0177 in forum Access
    Replies: 5
    Last Post: 06-29-2011, 08:47 AM
  4. ComboBox Search - No Results
    By cvansickle in forum Forms
    Replies: 5
    Last Post: 03-27-2011, 03:37 PM
  5. Bound Object Frame Combo sorted Results
    By kevsim in forum Programming
    Replies: 7
    Last Post: 01-08-2011, 06:30 PM

Tags for this Thread

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