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

bind a textbox in report to a field in tbl

Status
Not open for further replies.

axism

MIS
May 17, 2005
58
Hello,

I would like to know how you can bind a textbox to a field in a table using codes, let say on report.open session and on page session i want to change it to bind to some other field? this sounds stupid, but is this possible? Thanks in advance.
 
I'm sorry but I dont understand part of what you are asking. IF you want to look up a field in a table for a text box on a report take a look at dlookup. If you need more than that, I am not sure that I understand when you want it to change and to what.

I often use IIF expressions on text boxes in reports, then I can create my criteria, if its true point it to any field anywhere, and if not same deal. I can also include text or just put text, like "Exception Here"



misscrf

It is never too late to become what you could have been ~ George Eliot
 
my question was how to using code to change control souce for a txt box upon an event or using a sub or function.
 
Below is a section of code i added on a forms current event, you can add the same code to a button.

Private Sub Form_Current()
Me.mycontrol.ControlSource = "alternatecontrolsource"
End Sub

Reports are trickier as they are generally not friendly towards changing their data source on the fly. In a report you will need to use if statments when the report opens or on the section events. In the example below you must add all 3 accountno controls to the same report, however only the unbound control should be set to visible.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Accountno = 15601 Then
Me.accountnounbound = Me.accountno1
ElseIf Me.Accountno = 15601 Then
Me.accountnounbound = Me.accountno2
End If
End Sub

Hope this helps
H Jones
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top