SUB Form Population Help.

  • Thread starter Thread starter Brandon Johnson
  • Start date Start date
B

Brandon Johnson

I need to be able to populate a subform with the parent forms data. the
subform has about 7 textboxes and is in datasheet view. does anyone
know how to do that at all?

harborTemp = Replace(cboHarborClient, " ", "")
harborTemp = "z" & harborTemp
Set harborSub = CurrentDb.OpenRecordset(harborTemp, dbOpenDynaset)
harborSub.MoveFirst
Do Until harborSub.EOF

'WHAT GOES HERE

Loop
harborSub.Close
 
I need to be able to populate a subform with the parent forms data. the
subform has about 7 textboxes and is in datasheet view. does anyone
know how to do that at all?

Question: why ever would you WANT to do it?

What are the Recordsources of the form and subform?
Why do you want to (apparently) store data redundantly in two
different tables?
What is the structure of your database? I don't understand the point
of the Replace() and the "z" - how do they manage the data?
harborTemp = Replace(cboHarborClient, " ", "")
harborTemp = "z" & harborTemp
Set harborSub = CurrentDb.OpenRecordset(harborTemp, dbOpenDynaset)
harborSub.MoveFirst

harborSub.Edit ' first open the recordset for editing
Do Until harborSub.EOF

'WHAT GOES HERE

harborSub!ThisField = Me!ThisControl
harborSub!ThatField = Me!ThatControl
harborSub.Update ' actually write the record
harborSub.MoveNext
harborSub.Close

The fact that you're using MoveFirst suggests that you're overwriting
existing records, all with the exact same data (a very strange thing
to do). Are there in fact multiple records already on the subform? or
do you want to add one new record duplicating the data in the parent
form? or do you want to add (how many??) duplicate records to the
subform's recordsource?


John W. Vinson[MVP]
 
Back
Top