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

Extract values from Subform to use in VB code 1

Status
Not open for further replies.

apestaart

Technical User
Feb 5, 2004
107
NL
I am facing problems to get values from a subform for further use in Visual Basic code.
When I give Set Focus to my Form I can only read values from that Form and not from the subform.
I have tried to do it with Macro SetValue and VB code direct. Both give an error from the MS JET engine.

In my SubForm (listmode)I have 2 or 3 lines (records), I want to read the values from the first record.

The main form has data like ; Patientname, Address ....
The Subform has data like : First appointmentdate, Second appointmentdate .

By pressing a button on the main Form I start a report Conformation in whitch I need the value First appointmentdate.

Can someone help me with a macro or VB code how to do that?
I am familiar with Access but have limited experience with VB (just started 2 month ago)

Best regards Gerard van Beek

 
Assume that your main form is named frmMain, and your subform (on the main form) is named frmMainSubform, then to reference a control named SomeControl on the subform, you would use the following syntax:

Forms!frmMain!frmMainSubform.Form!SomeControl

This would return the value property of the current record for the nominated control on the subform.

Hope this helps,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Gerard,

Try: Forms!Contactpersonen!Afspraken_overzicht.Form!Soort_afspraak.

I dont know why, but you seem to be repeating the Afspraken_overzicht in your example.

Ditto with the recordset related code:

Set rs = Forms!Contactpersonen!Afspraken_overzicht.Form.recordsetclone

Hope this helps,

Totsiens,
Steve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top