Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Parameter Input to Form

Status
Not open for further replies.

GLG123

Technical User
May 4, 2006
10
0
0
US
I started a thread earlier this week about this. There's been a few changes since. In the end the VERY BASIC problem I CAN NOT figure out. It seems very simple.

I have a Form, it is linked to a Query, there is a Field in the query that has an expression needing a Parameter Input. I open the form, the parameter box pops up, I add data, the form opens. This part works just fine.

I want the data that I just input in the parameter box to appear in a text box that's on the form.

I've been around in circles wondering why some of the exact concepts apparently work with reports, but NOT forms.

TIA
 
How are ya GLG123 . . .

That was thread702-1227948

Remember my suggestion to use a [blue]Custom Function[/blue] instead of the [blue]parameter[/blue]! . . . hmmmmmmmm . . . I wonder . . .

Calvin.gif
See Ya! . . . . . .
 
Yes, I remember; and if I knew more about programming I'd definitely want to go that route. I am still looking to that for a long term solution, as I HOPE to be able to that. If you know of any good tutorials showing how to do that or general access-vba-sql tutorials, I'd like to know.

For now, I'm just confused as to why passing parameter input to a report works so easily; but to a form, I can't get it to work at all.

Thanks
 
GLG123 . . .

[ol][li]In the Declaration Section of a module in the modules window, copy/paste the following line:
Code:
[blue] Public UsrInput[/blue]
This is the [blue]Global Variable[/blue] that will hold the user input.[/li]
[li]Next . . . copy/paste the following function to the same module:
Code:
[blue]Public Function AnsPrompt()
   Dim Prmpt As String, Title As String
   
   Prmpt = "Enter a number"
   Title = "User Input!"
   UsrInput = InputBox(Prmpt, Title)
   AnsPrompt = UsrInput
   
End Function[/blue]
The function gets the user input and stores it in the global variable as well as returning the same. In your query/sql change the parameter to [blue]=AnsPrompt()[/blue][/li]
[li]Finally in the OnLoad event of the form:
Code:
[blue]   Me!YourTextboxName = UsrInput[/blue]
[/li][/ol]
[blue]Cheers! . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top