Compile error-variable not defined
The below is just a portion of code. I have an entire form and the odd thing is the same code on 3 other forms that load just fine. The only differences in each form is the queries in the sql portions. They only change by a minut amount. But, when I run this 1, the 4th one, I get an error: compile error, variable not defined. Then it takes me to the portion I have placed in blue and highlights in yellow the title of Private Sub Form_Load(). I am not sure what is wrong and have tried to debug with no luck. Thanks
Private Sub Form_Load()
Unload Form1
Screen.MousePointer = vbDefault
sPath = "\\HchznDB01\custmapp\Discharge\Discharge.mdb"
Set daoDB = DBEngine.OpenDatabase(sPath)
' recordset for updating boxes as completed
Set rsBoxFull = daoDB.OpenRecordset("tblboxno")
' lists patients in search box by Last Name, First Name, indexed by admission number and episode type
Set rsPatient = daoDB.OpenRecordset("SELECT * FROM Archived_Patients " & _
"LEFT JOIN tblboxno ON archived_patients.BoxNo = tblBoxNo.BoxNoID " & _
"WHERE Archived_Patients.EpsTyp = 'BR' " & _
"AND [OrgSys] = 75 ORDER BY [NamStr]")
Do Until rsPatient.EOF
lstPatient.AddItem RTrim$(rsPatient.Fields("NamStr")) & " " & _
rsPatient.Fields("dob")
lstPatient.ItemData(lstPatient.NewIndex) = rsPatient.Fields("AdmSys")
rsPatient.MoveNext
Loop
' lists only box numbers assigned to this branch/org and not yet marked complete
Set rsBox = daoDB.OpenRecordset("SELECT * FROM tblboxno " & _
"WHERE boxcomplete = false " & _
"AND branchname = 'HC HOSPICE SERVICES INC VIENNA' " & _
"ORDER BY vendorboxno")
Do Until rsBox.EOF
cboBox.AddItem rsBox.Fields("vendorboxno")
cboBox.ItemData(cboBox.NewIndex) = rsBox.Fields("boxnoid")
rsBox.MoveNext
Loop
' add items to drop down boxes
cboDept.AddItem "Branch"
cboDept.AddItem "Finance"
cboDept.AddItem "AR"
cboDept.AddItem "AP"
cboDept.AddItem "Payroll"
cboDept.AddItem "Corporate"
cboDept.AddItem "HCIS"
cboDept.AddItem "Rxpress"
cboDept.AddItem "Pharmacy"
cboDept.AddItem "HR"
' disable entry form boxes until patient is selected
txtDateArchived.Enabled = False
txtInitials.Enabled = False
cboBox.Enabled = False
cmdBoxFull.Enabled = False
cboDept.Enabled = False
txtComments.Enabled = False
' display count of all records for this branch
rsPatient.MoveLast
Label22.Caption = "Total Records: " & rsPatient.RecordCount
' set focus on patient search box
Me.Show
lstPatient.SetFocus
End Sub
|