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

Select Case to Change Control Source of a text Box

Status
Not open for further replies.

Krystoff

MIS
Sep 18, 2002
129
US
Hello again all,

I have a Select Case statement that I am trying to use to change the Control Source of a text box on a form based on what is selected in a Cbo Box

Here is my code:

Select Case Prod
Case "S001"
Forms!Letter!View_Body.ControlSource = DLookup("[Stan_Ltr]", "Tbl_Ltr", "[Let_Code] = S001")
Case Else
With CodeContextObject
Forms!Letter!View_Body.ControlSource = Ltr_V1(.Prod, .Act_Num)
End With
End Select

There a quite a few extra cases but I wanted to keep it simple.

The Case Else statement I am trying to get the Control Source to be another Function that I have.

Any help is appreciated!
Chris
 
Hi Chris!

The control source should be a string value that allows access to locate the information to put in the text box and/or the loctation to store the information entered into the text box. So, it you are truely trying to set the control source then you would need to use "=DLookUp(etc)" or "=Ltr-V1(Field1, Field2)" where field1 and 2 are part of the recordsource of the form. If you just trying to display the information or store the info in a table, then you want to use .Value instead of .ControlSource to actually fill in that value into the text box.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi Jeff!

I am actually trying to set the control source of the text box. The Dlookup statement I am using is trying to lookup the value of field in a different table than the record source of the Form. The criteria there is whatever they choose in the Combo Box.

The Ltr_V1([Prod],[Act_Num]) is trying to set it to a function that I have and Prod and Act_Num are fields on the
Form itself.

I have tried to run the code from the On Change event of the Combo Box. The code stops and gives me this error when I select S001.

Run Time Error 64479

The expression you entered as a query parameter produced this error: 'The object doesn't contain the Automation object 'S001."

When I select anything else it gives me a #Name? error in the text box.

Oh, and the text box is Unbound when I start up the Form.

Hope that clarifies!

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top