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!

Form Field Reference

Status
Not open for further replies.

mdr2271

Programmer
Sep 14, 2005
42
US
In Access 2002 how would I reference the field 'ID' in the form 'Main Sub1' in the before insert event? I want to have the code be something like:

Private Sub Form_BeforeInsert(Cancel As Integer)
Forms!Salutation1![ID] = Forms!Main sub1![id]
End Sub

It's been a long time since I've done any access or vb programming so I apologize for the dumb question.
 
It usually would work like you have it. It probably wont work right now though because the space in your form name. General naming conventions are against putting spaces in anything declared.

-Pete
 
Unfortunately I am taking over a 10 year old database that was developed bit by bit over time by different people that didn't follow any conventions.
 
Just use brackets . . .
Code:
[blue]    = Forms![red][b][[/b][/red]Main sub1[red][b]][/b][/red]![id][/blue]

Calvin.gif
See Ya! . . . . . .
 
2 cents more...

mdr2271 said:
how would I reference the field 'ID' in the form 'Main Sub1'

If the form name is the issue then AceMan's answer should solve it, but bear in mind that Tables have Fields and Forms have Controls.

Make sure that 'ID' is the Name of the text box. You could have a text box named Text1 with a Control Source of [ID] that has to be referenced as Forms![Main sub1]![Text1]









When Galileo theorized that Aristotle's view of the Universe contained errors, he was labeled a fool.
It wasn't until he proved it that he was called dangerous.
[wink]
 
Do yourself a big favor As Snyperx3 mentioned. Never use names for any object with spaces or reserved words in it. Sure you can make it work, but you are asking for problems somewhere down the line.

Forms!Main Form (error)
Forms!Controls (error)
Forms!frmMainForm (no Problem)
Forms!frmControls (no problem)

Make it work
Forms("Main Form")
Forms![Main Form]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top