Assign to private variable from a subform

NT100

Registered User.
Local time
Tomorrow, 03:19
Joined
Jul 29, 2017
Messages
148
Hi,

I built a main form, a private variable and a subform. If the user clicks to select from subform, I'll assign that private variable declared in main form to the value of the selected item in subform. The work is listed below

frmTutor ' this is Main Form
Option Compare Database
Option Explicit
Private iTApptID As Long
...


Private Sub Form_Click() ' This is a subform

iTApptID = Forms!frmTutor!sbfApptHistory.Form!ID

However, I got a compile error of variable not defined.

How come?
 
You have defined a variable as Private in a form so it's not available outside that form.
Define it as Public in a standard module or just reference the Forms!.... code and omit the variable
 

Users who are viewing this thread

Back
Top Bottom