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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Key Function

Status
Not open for further replies.

TheCleaner

Technical User
Apr 21, 2001
19
US
Hello back with another. I'm looking for a SendKey function that would copy the text that I have in a field [FieldOne] into another filed [FiledTwo]on the same form (FormOne). This would take place when the user changes the value in a combo box. It will not be visible to the user, however it would be just like performing "cntrl+c" of [FieldOne] and then going to [FieldTwo] with "ctrl+v'. There may be another way, however the Setvalue will not work.
The first field [FieldOne] is coming from a query that searches a table ("TableOne"). That query has a perameter based on the value that the user selects in a [ComboBoxOne] on FormOne. [FieldOne] is displayed on FormOne no problem. But when the record is saved it will not allow me to Setvalue of [FieldOne] to [FieldTwo]. If it does [FieldTwo] is blank in TableOne. My quess is because the value in the query is going away thus making the value in [FieldOne] go away.
Some may recognize this is a problem I've been wrestling with for some time.I know it sounds nuts to be saving the same value in a different field in the same table, just trust me. The label names have been change to protect the ignorant(me) :). Thanks for any help. Sorry so long.
 
In the after Update event of the Combo Box add the following.

me.[FieldTwo] = me.[FieldOne]

This assumes that FieldTwo and FieldOne are names of controls (text boxes) on the current form. Terry

;-) USER, n.: The word computer professionals use when they mean "idiot." -Dave Barry

SQL Article links:
 
Nope FeildOne is a List box and FieldTwo is a text. I got a run time error 2448. Can't assign a value to this object. so on and so forth. Thank you
 
Help me understand your process.

A user makes a choice in a combo box. That choice is used as criteria in a query that then fills a list box (FieldOne). You want a value from the list box placed in the text box (FieldTwo) and ultimately in the table (TableOne).

If I have it right so far then continue else stop reading and tell me where I've gone wrong.

--------------

In order for a value to be extracted from a list box a selection must be made. A list box can have multiple selections. Do you want one, more than one or all of the entries in the list box stored in the text box (FieldTwo)? How you set the value of the text box from the list box depends on how you answer the preceding question.

In the simplest case, you place the following code in the "After Update" event of the list box to set the text box value = the one item selected in the List Box.

me.FieldTwo=me.FieldOne

It gets more complex with multiple choices and will require coding a loop to process all the items selected in the List Box. Terry

;-) USER, n.: The word computer professionals use when they mean "idiot." -Dave Barry

SQL Article links:
 
THANK YOu! Everything you said is dead on. I used a list box for FieldOne because it was the only type that would return the value in the query. The text box with a control source or even default value of
"=[QueryOne]![QueryFieldOne]" would give me a #Name? Eventhough I have an event procedure for the combox to requery the textbox if the user changes the info in the combobox.
Private Sub Combo_Box_One_AfterUpdate()
'Requery FieldOne text box.
Me!FieldOne.requery
End Sub

The query only returns one record and only one value for the list box(FiledOne). So I didn't think that would be a problem. I tried making the list box look up the value in the query but store it in the table when i close/save the form(the Ultimate goal), but I can't seem to figure it out. Thanks VERY much. J
 
You could use DLookup in a Text Box to return a value. Set the Control Source of the Text Box to =DLookUp("[Col1]","Table","criteria"). Terry

;-) USER, n.: The word computer professionals use when they mean "idiot." -Dave Barry

SQL Article links:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top