Problem referring to subform controls

K

Kurt

I have a main form (frmCustomers) with two subforms
(fsubCalls and fsubCallNotes). The two subforms are based
on tblCalls.

- fsubCalls is linked to frmCustomers (on CustomerID).
It's in datasheet view.

- fsubCallNotes is linked to fsubCallNotes.

When the user enters a customer's call (in fsubCalls), he
can also enter notes for that call (in fsubCallNotes).

Here's the problem:

When the user enters a new call and then clicks in the
Notes subform, he gets this error:

"You tried to assign a Null value to a variable
that is not a Variant data type."

I assume it's because the call record needs to be saved
before moving to the Notes subform. So I tried adding some
code but it's not working (see comments in line):

Private Sub fsubCallNotes_Enter()
If IsNull(Me![CallID) Then
MsgBox "You must enter a call before adding notes."
'Set focus on a the call field in fsubCalls
'PROBLEM: Doesn't set focus. Appears to just exit
'sub.
Forms!frmCustomers!fsubCalls.Form!CallDate.SetFocus
Exit Sub
Else
'Save info in fsubCalls to establish a CallID
'PROBLEM: Appears to create a recursive code
'situation - form blinks and jumps for about
'10 seconds then resolves.
DoCmd.GoToControl "fsubCalls"
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
DoCmd.GoToControl "fsubCallNotes"
End If
End Sub

--------------------------

I assume it has something to do with how I'm referring to
the subforms?

Kurt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top