Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2005, 02:08 PM
Registered User
 
Join Date: Feb 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old February 15th, 2005, 04:15 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You have mispelled cmdBoxFull, I would say, either in naming it on the form, or here in the code.





Similar Threads
Thread Thread Starter Forum Replies Last Post
variable not defined error? SKhna ASP.NET 2.0 Basics 1 April 1st, 2008 05:48 AM
Help : compile error : sub or function not defined Specialist VB How-To 2 June 20th, 2007 04:34 AM
Appl-defined or Object-defined error 1004 chp Excel VBA 3 April 4th, 2006 08:12 AM
Compile Error: Variable not defined Fin Excel VBA 0 February 1st, 2006 01:45 PM
Application-defined or object-defined error James Excel VBA 1 August 12th, 2003 11:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.