Total newb question about forms

gustoaf

New Member
Joined
Sep 23, 2008
Messages
4
I have a simple form with a single button on it that will run a query based on user input. Instead of that input returning the spreadsheet-type query results, how can I have the results display in text boxes on the same form?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
For instance, my form button runs the query:<o:p></o:p>
<o:p> </o:p>
SELECT UNIT_ID.UNIT_ID, UNIT_ID.MNEUMONIC, CORR_CODE.CORR_COND, CORR_CODE.MESSAGE<o:p></o:p>
FROM CORR_CODE INNER JOIN (UNIT_ID INNER JOIN CORR_DATE ON UNIT_ID.UNIT_ID = CORR_DATE.UNIT_ ID) ON CORR_CODE.CORR_COND = CORR_DATE.CORR_COND
WHERE (((UNIT_ID.UNIT_ID)=[Enter Unit ID]));<o:p></o:p>
<o:p> </o:p>
Unit_id.unit_id is a unique key with no duplicates so only one record will return. I would like the 4 ‘select’ fields to populate text boxes at the bottom of the same form that the input button is on. A bonus would be for the text boxes to be hidden until a result is returned.<o:p></o:p>
<o:p> </o:p>
Hope I explained that well enough. <o:p></o:p>
 

tinkythomas

Active Member
Joined
Dec 13, 2006
Messages
432
Hi,

No need for a command button if you take this approach. Just create a new form by selecting forms and then click Create form by using wizard. Then select your query from the combo box.

Next select the fields that you want on the form and click next. Select the layout, I suggest tabular. Next select the style and then click next and name your form.

Now when you click finish the form will open displaying the fields in textboxes that the wizard has created for you. You can of course change the layout from form design.

Hope that helps.
 

tinkythomas

Active Member
Joined
Dec 13, 2006
Messages
432
Sorry just read your post again and I missed that you had a textbox for user input.

Just add a textbox to the form header section of the form created by the wizard. Reference this new textbox in the criteria from your query. Now add this code to the after update event of the new textbox.....
Code:
Option Compare Database
Option Explicit

Private Sub Text14_AfterUpdate()

    Me.Form.Requery    'run the query

End Sub
Now after the user enters criteria, the query will execute and the records will be displayed in the textboxes you created with the wizard.

Hope that helps.
 

Forum statistics

Threads
1,081,561
Messages
5,359,612
Members
400,540
Latest member
JimUSMC

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top