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

Record Source = to name of Form

Status
Not open for further replies.

beckwiga

Programmer
Mar 30, 2005
70
0
0
Hello all,

What is the best way to programmatically set my Record Source(on the Data tab of my form) to the Name of the Form itself?(I will also have a table with the same name as the Form which is what I will really be using as my Record Source) Can I just code this in the Data tab, or do I need to do this in VBA somehow in an OnOpen event, setting my .RecordSource to something. Any ideas? This is Access 2003.

Any input would be appreciated.
 
In the Open event procedure:
Me.RecordSource = Me.Name

But why doing it programmatically ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
beckwiga . . . . .

The RecordSource of a form can be:
[ol][blue][li]TableName[/li]
[li]QueryName[/li]
[li]SQL (not in your case)[/li][/blue][/ol]
[purple]Unless you intend to name one of the above onjects your form name . . . . whats the point!?[/purple]

Calvin.gif
See Ya! . . . . . .
 
beyond the obvious, this is a POOR practice. Having different objects with the same name confuses both people and (at least occassionally) the programming. Look up something called Reddick or most any naming convention you can find in most any text re programming in general.





MichaelRed


 
MichaelRed is right! You should NEVER name multiple objects exactly the same. When I do a really big project, I'll use a common root name and tag on the object type. Thus, for a portion of the app dealing with visit reports, I'll use VisitReportsForm, VisitReportsQuery and VisitReportsReport. This way you (and anyone down the road, following in your footsteps) can readily tell what goes with what, without confusing Access!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top