triggering data entry from a combo box

  • Thread starter Thread starter Jody
  • Start date Start date
J

Jody

I have two tables, tblSubscriber and tblService. I would
like to trigger the automatic entering of a value in a
field (in tblSubscriber) called 'unitnum' after selecting
the equivalent value from a combo box whose control source
is a field in tblService called 'baseunit'. I feel that
it must be an AfterUpdate event for the combo that will
trigger the data entry in the other table, but I'm not
sure of the code.

The linking field between the two tables is SubscriberID,
which is the primary key of tblSubscriber and a foreign
key in tblService.

Any ideas what the code should be?

Thanks,
Jody
 
thanks Ken. that worked, but since the textbox being
filled is on a different form than the combo box, the form
needs to be saved to complete. That save command has to
be part of the Combo box AfterUpdate event. Any idea what
the code would be to save a record on another form?

Thanks again,
Jody
 
I haven't tried this, but I imagine that it would work.

In your code, after you set the value of the textbox on the other form, you
could try these code steps:

DoCmd.SelectObject acForm, "NameOfTheOtherForm", False
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SelectObject acForm, Me.Name, False

Just out of curiosity, why do you need to save the record on the other form?
Can you give a little more details? There may be another way of doing what
you seek to do.
 
Hi Ken,

Actually, the user will save the value (as part of the
record) manually.

Really, the other form "frmSubscriberMain" doesn't have to
be saved until this time, so your originally suggested code
could be executed either within the combo After_update or
the Form After_update.

I've tested your code in both after_updates, and I am
getting just a slight glich. The error 'the object
'frmSubscriberMain' isn't open' appears in either case.

Just to remind, here is the code:

Private Sub BaseUnitCode_AfterUpdate()

'This is the combo on the Installation page
'Place value selected also in SubsNumber on frmSubscriberMain

Forms!frmSubscriberMain.SubsNumber.Value =
Me.BaseUnitCode.Column(0)

'Save frmSubscriberMain
DoCmd.SelectObject acForm, "frmSubcriberMain", False
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SelectObject acForm, Me.Name, False

End Sub

I think we are very close. Just a matter of having Access
recogize that frmSubscriberMain is open.

Thanks again for your help,
Jody
 
Hi Ken,

I have a bit of egg on my face. I spelled frmSubscriber as
frmSubcriber in my code:

DoCmd.SelectObject acForm, "frmSubcriberMain", False

After correcting this, I'm back to square 1 -
frmSubscriberMain remains in an edit position (showing the
pencil). However, as soon as I click anywhere outside of
my subform, the pencil in frmSubscriberMain disappears.

As an alternative, any way to programatically achieve the
equivalent of 'clicking' outside of the subform while
keeping it showing? I have a search combo that I can give
the focus to, while keeping the subform in view. How would
I put the focus on that combo?

Cheers,
Jody
 
Hi Ken,

Sorry I'm just getting back to you - I ended up working
around this issue and I'm finally getting back to you to
close the loop. Thanks for your help and patience.

Cheers,
Jody
 
Back
Top