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!

Getting data from a field

Status
Not open for further replies.

jkdprime

Technical User
Sep 28, 2005
6
US
I am trying to get data from two fields on my form. One is a text field and one is a combo box. I am extracting this information to put into a query. I know I used to use the .Value (Forms![Object].Value) in the older versions of access (using access 2003 now).

For Example: my data base has to fields - Card Type (Combo Box) and Card No (text field). Once I fill those two fields in, I want to pass the information in the two fields into a query, which is envoked by a button press.
 
You can use notation of the style

Forms![Form name].[Control name]

directly in your query as long as the query is open.
 
Ooops, mistake in my last post...

...as long as the form is open.

(Small typo, BIG difference)
 
Pass the values on to a variable in the Click Event for the form:
Dim myText as String
Dim myCombo as String

Sub myButton on_click()
myCombo = CardType.value
myText = CardNo.value
End Sub
Then when constructing the SQL statement use myText and myCombo as the values for the query.
 
The problem with using the .Value is that it is now used for a boolean expression (TRUE or FALSE).
 
When I use - Forms![Form name].[Control name] I get an error Too few paramters - Expected 1
 
Switch the exclamation mark with the fullstop:

Forms.frmName!ctrlName.Value
 
I get a syntax error using this notation Forms.frmName!ctrlName.Value
 
The problem is I am not working with subforms. The object I am creating is on the same form
 
So, simply use:
Forms![Form name]![Control name]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top