Tables("MainTable").mycombo = Me.CurrentRecord.IDField ?

  • Thread starter Thread starter Chris K
  • Start date Start date
C

Chris K

I have Mainform which includes a combo linked to a tied ID field with a look
up to contact details in a SecondTable

If the user needs to add a new contact (not in list), I have a SecondForm
for the SecondTable which pops up so they can add/edit records

the SecondForm is continuous to allow easy adding/editing

After they have finished adding/editing I want to pass the IDField of the
currently selected record back to the combo on the MainForm

Questions:

1/ Should I write the value to the form/combo or direct to the MainTable?

2/ How do I refer to the IDField contents on the currently active record
(where the cursor is) on the SecondForm

Form Close

Tables("MainTable").mycombo = Me.CurrentRecord.IDField ?
 
Chris K said:
I have Mainform which includes a combo linked to a tied ID field with a
look up to contact details in a SecondTable

If the user needs to add a new contact (not in list), I have a SecondForm
for the SecondTable which pops up so they can add/edit records

the SecondForm is continuous to allow easy adding/editing

After they have finished adding/editing I want to pass the IDField of the
currently selected record back to the combo on the MainForm

Questions:

1/ Should I write the value to the form/combo or direct to the MainTable?

2/ How do I refer to the IDField contents on the currently active record
(where the cursor is) on the SecondForm

Form Close

Tables("MainTable").mycombo = Me.CurrentRecord.IDField ?

P.S. I dont really want to include IDField as a control so would need to
refer to it as a field/value not a control/value
 
Marshall Barton said:
Those bleep lookup fields can really confuse things. The
main form combo box IS the IDField control, check its
ControlSource property.

Your entire question should be moot because the combo box's
NotInList event, properly coded, will take care of all the
thigs you are concerned about. Make sure that the
SecondForm is opened in dialog mode and the NotInList
procedure set the Response argument to acDataErrAdded.

You could see what's really happening in the table if would
stop trying to make the table's datasheet look nice and set
the field's lookup property back to Text Box.

Not sure that I've explained correctly - the SecondForm is continuous
(displaying many/all records) - when it's opened from MainForm the
combo/IDfield could well be Null
Currently if the user doesn't want an existing contact (not in list), they
pop up SecondForm, adds new contact/record, closes SecondForm and chooses
the new record/contact from the combo list
The user can also open SecondForm to edit existing contact details (phone
number, etc)
Just thought it would be neater to identify which record (of many) they had
selected at the time they closed SecondForm and write this directly to
MainForm.IDField
 
Marshall Barton said:
In the contacts form's Close event, try using:

Forms!MainForm.IDField = Me.IDField

Tried this and it works fine but it always returns IDField of 1st record on
the SecondForm (continuous), irrespective of which record is selected

I'm getting the impression that I am doing something very unorthodox because
the Secondform only wants to display the first record (I have to manually
expand it to see other records)?

It's as if forms are only designed to display one record at a time but then
I'm puzzled what is the purpose of continuous form design?
 
Marshall Barton said:
Chris said:
"Marshall Barton" wrote
Chris K wrote:
Chris K wrote:
"Chris K" wrote

I have Mainform which includes a combo linked to a tied ID field
with
a
look up to contact details in a SecondTable

If the user needs to add a new contact (not in list), I have a
SecondForm
for the SecondTable which pops up so they can add/edit records

the SecondForm is continuous to allow easy adding/editing

After they have finished adding/editing I want to pass the IDField
of
the
currently selected record back to the combo on the MainForm

Questions:

1/ Should I write the value to the form/combo or direct to the
MainTable?

2/ How do I refer to the IDField contents on the currently active
record
(where the cursor is) on the SecondForm

Form Close

Tables("MainTable").mycombo = Me.CurrentRecord.IDField ?

P.S. I dont really want to include IDField as a control so would need
to
refer to it as a field/value not a control/value [snip]

In the contacts form's Close event, try using:

Forms!MainForm.IDField = Me.IDField

Tried this and it works fine but it always returns IDField of 1st record
on
the SecondForm (continuous), irrespective of which record is selected

I'm getting the impression that I am doing something very unorthodox
because
the Secondform only wants to display the first record (I have to manually
expand it to see other records)?

It's as if forms are only designed to display one record at a time but
then
I'm puzzled what is the purpose of continuous form design?


That's an odd problem. I assume you have the second form's
detail section's Height set tall enough for several records.
The only thing I can think of is that somehow the form is
filtered to only display one record.

You said earlier that users can scroll through the contact
records so it sounds like at some point you can see more
than one record and select/edit/add a record. Let's try
using the Unload event instead of the Close event and see
what happens.

Sorted it finally

because all controls/fields/values are identical for each record on
continuous form, you can only use the form_current event to distinguish
between records

Private Sub Form_Close()
Forms!MainForm.IDField = ID.Tag
End Sub

Private Sub Form_Current()
IDField.Tag = IDField
End Sub

Thanks for the input
 
Back
Top