+ Reply to Thread
Results 1 to 5 of 5

Pass UserForm variables into Query

  1. #1
    Registered User
    Join Date
    10-02-2013
    Location
    Norfolk
    MS-Off Ver
    Excel 2007
    Posts
    9

    Pass UserForm variables into Query

    I am trying to create a userform that will allow me to change the criteria of a query i.e. search based on surname and DOB. I recorded a macro to give some idea of what I am trying to do:

    Please Login or Register  to view this content.
    I thought it might be as simple as tweaking the above code with a TextBox.Value approach? Any help will be greatly appreciated.
    Last edited by allend5; 03-02-2015 at 10:00 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Pass UserForm variables into Query

    Indeed, you can include textboxvalues into a query in a manner similar to:
    Please Login or Register  to view this content.
    etc.

    But if you plan to use the forum please adhere to forum rules (edit your post).

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    10-02-2013
    Location
    Norfolk
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Pass UserForm variables into Query

    Hi Kaper,

    Fairly new to this forum business as you have highlighted. I have updated my post thank you for pointing this out. I have tried your code and it works. There are however a couple of questions that I have. DateBox I am assuming that this is another Control option available in userforms, however this appears to be missing from my toolbox? Secondly is it possible to have the results of this code display in a list box?

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Pass UserForm variables into Query

    No, I just used such names (when I design userform I try to have meaningful names to all controls) so if you not played with your userform, probably these textboxes are just textbox1, textbox2 etc.

    Of course you could use a kind of datepicker control (not in a toolbox - but see for instance here: http://www.rondebruin.nl/win/s8/win003.htm )

    As for last part - it's a side question, not fitting thread title, so may be better search forum for (probably answered here) and if not found possibly start a new thread.
    You could also start reading for instance: http://www.excelforum.com/excel-prog...o-listbox.html or http://www.fontstuff.com/vba/vbatut10.htm

  5. #5
    Registered User
    Join Date
    10-02-2013
    Location
    Norfolk
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Pass UserForm variables into Query

    Kaper,

    Thank you for your help. As I say this is all fairly new to me so will probably create a new thread.

    Regards,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Pass Value of combobox selected in Userform as input to textbox of other userform
    By Pradeepg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2013, 10:32 AM
  2. Get UserForm checkbox caption and pass to another UserForm on click or mouse down
    By tulsaguy71 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-08-2013, 11:07 AM
  3. [SOLVED] Pass variables from userform to module
    By Bishonen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2012, 07:54 AM
  4. Pass Userform values to UF variables
    By PNCD1957 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2011, 02:18 AM
  5. [SOLVED] Pass environmental variables?
    By Gunkie in forum Excel General
    Replies: 2
    Last Post: 03-07-2005, 07:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1