Results 1 to 8 of 8
  1. #1
    eliotchs is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    24

    Listbox conaining querylist??

    Hi,

    I'm looking to create a form which has a listbox of all the queries in the DB. I
    then want the user to choose a query from the listbox, and the query will update
    a field with the current date

    Any ideas where to start?

    Thanks


    Joe

    I think I got the SQL for the update part,
    I need the part to choose the query from a listbox..
    Thanks
    Joe
    Last edited by eliotchs; 03-31-2011 at 08:05 AM. Reason: addind info

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    alrighty Joe,

    look in your MSYSobjects table, which is a system table. Look under the NAME field to find one of your query names and use the TYPE field to identify all of them. after that, it's simply an sql statement.

  3. #3
    eliotchs is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    24
    Hi Adam,

    Thanks, I got that in a listbox..

    now how can I setup a command onclick of a button

    to runsql that would run it

    I got this under onclick..

    Dim SQLText As String
    SQLText = "UPDATE [" & Me.lis4 & "] SET [" & Me.List4 & "].submitteddate=date()"
    DoCmd.RunSQL SQLText



    Thanks
    Joe

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    docmd.openquery me.listboxname

    OR

    docmd.openquery(me.listboxname)

  5. #5
    eliotchs is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    24
    sorry,

    I didnt explain it right..

    What I wanted was to choose the query from the listbox then update "Datefield" with current date

    thanks again..
    Joe

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by eliotchs View Post

    What I wanted was to choose the query from the listbox then update "Datefield" with current date
    that doesn't make sense, sir.

    update a field with the current date? you don't need a query for that. is that ALL you want to do??

  7. #7
    eliotchs is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    24
    yes , but I want a user to choose the query to run the update query..
    via a form ..

    Is there an easier way?

    Thanks

  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    choosing a query is not really even relevant. why don't you just assign the box a value in code?
    Code:
    me.datefield = date()
    but if you want to actually provide the illusion to your users that they need to do something that requires thought to get this done, try something other than a list of query names. That just doesn't make sense. more than likely you'll confuse the heck out of your users if they start thinking they need to be using a query for a sophisticated task when this date assignment is all that's really happening.

    that's not really honest anyway. and not very good practice either, IMO.

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

Similar Threads

  1. Listbox Help
    By allykid in forum Programming
    Replies: 2
    Last Post: 03-30-2011, 06:17 AM
  2. INSERT INTO with listbox
    By TheShabz in forum Programming
    Replies: 6
    Last Post: 11-30-2010, 12:19 PM
  3. How do I get data from a listbox?
    By cowboy in forum Programming
    Replies: 1
    Last Post: 06-15-2010, 02:28 PM
  4. Listbox question
    By uaguy3005 in forum Access
    Replies: 1
    Last Post: 03-05-2010, 08:35 AM
  5. Columns in a Listbox
    By craigalaniz in forum Access
    Replies: 3
    Last Post: 01-07-2010, 01:11 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