borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to copy tables from one database to another)Next Topic (Disconnected recordset to Access database) New Topic New Poll Post Reply
AndreaVB Forum : Database : Call Display for recordset data not working
Poster Message
Nmacp
Level: Guest


icon Call Display for recordset data not working

Hi can someone help. frmCompSoft Call DisplayCompSoftData isn't working.  Can someone point me in the right direction?

Option Explicit

Private Sub cmdAdd_Click()

    Call InitialiseCompSoftData
    cmdUpdate.Caption = "Save Details"
        
End Sub

Private Sub cmdExit_Click()

    Unload Me
    
End Sub

Private Sub cmdNext_Click()

    rsCompSoft.MoveNext
    If Not rsCompSoft.EOF Then
        Call DisplayCompSoftData
    Else
        MsgBox ("End of file")
        rsCompSoft.MoveLast
    End If
    
End Sub

Private Sub cmdPrevious_Click()

    rsCompSoft.MovePrevious
    If Not rsCompSoft.BOF Then
        Call DisplayCompSoftData
    Else
        MsgBox ("Beginning of file")
        rsCompSoft.MoveFirst
    End If
    
End Sub

Private Sub cmdUpdate_Click()

    If cmdUpdate.Caption = "Update" Then
        Call WriteCompSoftData
        rsCompSoft.Update
    Else
        rsCompSoft.AddNew
        Call WriteCompSoftData
        rsCompSoft.Update
        cmdUpdate.Caption = "Update"
    End If
    
End Sub

Private Sub Form_Load()

    Me.Left = 700
    Me.Top = 200
    Call OpenCompSoftTable
    If Not rsCompSoft.EOF Then ' check for an unlikely event nothing is in the file
        rsCompSoft.MoveFirst
        Call DisplayCompSoftData
    Else
        Call InitialiseCompSoftData
    End If
    
    frmUpdateApp.mnuFile.Enabled = False
    
End Sub

Private Sub Form_Unload(Cancel As Integer)

    frmUpdateApp.mnuFile.Enabled = True
    Call CloseCompSoftTable
    
End Sub

10-09-2002 at 01:09 PM
| Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: Call Display for recordset data not working

Hi,
Need more info. What is "not working"?
Q: Is the call being made in the right place? Check BOF/EOF.
Q: Does DisplayCompSoftData work when called?
Kieron

____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

11-09-2002 at 07:47 PM
View Profile Send Email to User Show All Posts | Quote Reply
Nmacp
Level: Guest

icon Re: Call Display for recordset data not working

Hi,
Under Private Sub Form Load
the error msg is:
Sub or function not defined. In regards to:
Call DisplayCompSoftData

Thanks,

Nicolla

11-09-2002 at 11:30 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Call Display for recordset data not working

Actually there is no:
    OpenCompSoftTable
    DisplayCompSoftData
    InitialiseCompSoftData
    CloseCompSoftTable

Since you put Call x (where x = something from the list) I'd have to assume you've left out some important routines from your code.

12-09-2002 at 07:39 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: Call Display for recordset data not working

Check that your routines are not declared as "Private", if in doubt, always specify PUBLIC or PRIVATE when coding. I assume your DisplayCombSoftxxx routines are in a module, if so, they should be declared as Public Sub DisplayCompSoftxxx etc.

____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

13-09-2002 at 12:14 AM
View Profile Send Email to User Show All Posts | Quote Reply
Nmacp
Level: Guest

icon Re: Call Display for recordset data not working

Hi
From the module code the record set CompSoft is Public see below. The coding for the rsEmployee works fine ic an add records and edit them. On comparing rsEmployee with the rsCompSoft the coding for rsCompSoft looks ok. I can't figure out why it's saying that sub or function not defined. Thanks, Nicolla.

Option Explicit

Public dbSoftware As Connection
Public rsCompSoft As Recordset
Public rsEmployee As Recordset
Public rsEmployeeSubs As Recordset
Public CurrentEmployee As Long 'by definition the autonumber is long thats why you make it  a long'


Sub Main()
  
    frmUpdateApp.Show

End Sub

Sub InitialiseEmployeeData()

    frmUpdateEmployee.txtEmployeeID = ""
    frmUpdateEmployee.txtFirstName = ""
    frmUpdateEmployee.txtLastName = ""
    
End Sub

Sub InitialiseCompSoftData()

    frmUpdateSoftware.txtSoftwareID = ""
    frmUpdateSoftware.txtSoftwareName = ""
    
End Sub

Sub DisplayEmployeeData()

    frmUpdateEmployee.txtEmployeeID = rsEmployee("EmployeeID")
    frmUpdateEmployee.txtFirstName = rsEmployee("FirstName")
    frmUpdateEmployee.txtLastName = rsEmployee("LastName")
    
End Sub

Sub DisplaySoftwareData()

    frmUpdateSoftware.txtSoftwareID = rsCompSoft("SoftwareID")
    frmUpdateSoftware.txtSoftware Name = rsCompSoft("Software Name")

        
End Sub

Sub DisplaySoftUsersData()

    frmUpdateSoftwareUser.txtEmployeeID = rsEmployee("EmployeeID")
    frmUpdateSoftwareUser.txtLastName = rsEmployee("LastName")
    frmUpdateSoftwareUser.txtFirstName = rsEmployee("FirstName")
    frmUpdateSoftwareUser.txtSoftwareID = rsSoftware("SoftwareID")
    frmUpdateSoftwareUser.txtSoftwareID = rsSoftware("SoftwareID")
    
    Call OpenEmpSoftSubsQuery 'Opens a query from the database SQL'

    If rsEmpSoftSubs.RecordCount > 0 Then 'means that an employee record is greater than 0 an enrollment is found'
        frmUpdateSoftwareUser.txtEmployed = "Yes"
        CurrentEnrol = rsEmpSoftSubs("Enrol Sequence") 'Saved the sequence'
        frmUpdateSoftwareUser.cmdChangeEmployed.Caption = "Delete Employed"
    Else
        frmUpdateSoftwareUser.txtEmployed = "No" 'if no add a caption add Employed'
        frmUpdateSoftwareUser.cmdChangeEmployed.Caption = "Add Employed"
    End If
    
    Call CloseEmpSoftSubsQuery
                          
End Sub

Sub WriteEmployeeData()

    rsEmployee("EmployeeID") = frmUpdateEmployee.txtEmployeeID
    rsEmployee("Last Name") = frmUpdateEmployee.txtLastName
    rsEmployee("First Name") = frmUpdateEmployee.txtFirstName
  
    
End Sub

Sub WriteCompSoftData()

    rsCompSoft("SoftwareID") = frmUpdateSoftware.txtSoftwareID
    rsCompSoft("Software Name") = frmUpdateSoftware.txtSoftwareID
    
    
End Sub



Sub OpenCompSoftTable()
    
    rsCompSoft.Open "CompSoft", _
        dbSoftware, adOpenStatic, adLockOptimistic, adCmdTableDirect
    
End Sub

Sub OpenEmployeeTable()
    
    rsEmployee.Open "Employee", _
        dbSoftware, adOpenStatic, adLockOptimistic, adCmdTableDirect
    
End Sub

Sub OpenEmpSoftQuery()

    Dim SQLStr As String
    
    SQLStr = "SELECT * FROM [SoftwareUsers] " & _
            "WHERE [EmployeeID] = '" & rsEmployees("EmployeeID") & "' " & _
            "AND [SoftwareID] = '" & rsCompSoft("SoftwareID") & "'"
    
    rsEmployee.Open SQLStr, _
        dbSoftware, adOpenStatic, adLockOptimistic
    
End Sub

Sub OpenDatabase()
    
    Set dbSoftware = New ADODB.Connection
    dbSoftware.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=Software.mdb;"
        
    Set rsCompSoft = New Recordset 'set means create objects but do nothing with them'
    Set rsEmployee = New Recordset
    Set rsEmployeeSubs = New Recordset

    
End Sub

Sub CloseEmployeeTable()

    rsEmployee.Close
      
End Sub

Sub CloseCompSoftTable()

    rsCompSoft.Close
      
End Sub



Sub CloseEmpSoftQuery()

    rsEmpSoft.Close
      
End Sub

Sub CloseDatabase()

    dbSoftware.Close
    Set dbSoftware = Nothing 'removes object from memory'
    Set rsCompSoft = Nothing
    Set rsEmployee = Nothing
    Set rsEmployeeSubs = Nothing
      
End Sub

13-09-2002 at 11:21 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Call Display for recordset data not working

If you turn off the "Enable emoticons in this post?" your code will look better.

You don't have a: DisplayCompSoftData
you do have a:
     DisplaySoftwareData
     DisplayEmployeeData
     DisplaySoftUsersData

Oh and for two comments (not important for it not working or anything):
1) It looks as if most of the "public" routines you have in the module could easily be in 2 forms, since you're referencing them from it.
2) Put "Private|Public" (either, Public in your case) in front of the Sub.


[Edited by JLRodgers on 14-09-2002 at 03:37 PM GMT]

14-09-2002 at 09:33 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Nmacp
Level: Guest

icon Re: Call Display for recordset data not working

Hi,
JLRodgers thanks I can see why it wasn't working now. Thanks a heap

16-09-2002 at 02:58 PM
| Quote Reply
AndreaVB Forum : Database : Call Display for recordset data not working
Previous Topic (How to copy tables from one database to another)Next Topic (Disconnected recordset to Access database) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder