Results 1 to 6 of 6
  1. #1
    wnicole is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    118

    OnClick event to view Total Count records

    I created a query that give me Total Count of invoices in a particular type of job. I made a datasheet form. Now I want to click on the TotalCount of records to open the form to view only the records in that type of job. THis is what I'm using but its not working. Can you tell me what I'm doing wrong?

    DoCmd.OpenForm "datasht_AllInvoices", , , "[Type of Job]=" & "'" & [Type of Job] & "'"

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Is [Type of Job] text vs. numeric? Because your code is set up as if it is text type.

    Maybe save the datasheet form before executing the DoCmd and or use Me.[Type of Job].Value in your statement.
    DoCmd.OpenForm "datasht_AllInvoices", , , "[Type of Job]=" & "'" & Me.[Type of Job].Value & "'"

  3. #3
    wnicole is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    118
    Yes it is a text, however I forgot to tell you that it is also a listbox. Would that change the code?
    FYI...I did use DoCmd.OpenForm "datasht_AllInvoices", , , "[Type of Job]=" & "'" & Me.[Type of Job].Value & "'" and still didnt work...
    Do you think the fact that Type of job is a listbox?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    If the ListBox has its Multiselect property = to Yes, you will need to iterate the control. Here is an example.
    https://www.accessforums.net/forms/l...tml#post276307

    If it is not a multiselect listbox, I believe you can use the .Value property to retrieve the selected. You just need to be sure to set the Bound Column property to the correct column.

  5. #5
    wnicole is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    118
    Sorry I think this one is over my head :-(

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Perhaps you can test which element the user selected by using a msgbox. Maybe place the following code in the AfterUpdate event of your ListBox Control.
    Code:
    msgbox Me.[Type of Job].Value

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

Similar Threads

  1. Replies: 6
    Last Post: 02-23-2014, 03:54 PM
  2. Replies: 5
    Last Post: 12-03-2013, 01:25 PM
  3. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  4. Onclick event
    By tmcrouse in forum Forms
    Replies: 3
    Last Post: 09-18-2010, 01:10 PM
  5. OnClick event
    By HotTomales in forum Forms
    Replies: 1
    Last Post: 12-24-2009, 08:10 PM

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