Compile Error: Expected Function or Variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrel
    New Member
    • Nov 2006
    • 72

    #1

    Compile Error: Expected Function or Variable

    Hello, i need you help, can someone whats the cause of getting an error of Expected function or variable, its like this i have a function code in a module and call it on my main form.. here my code:
    Code:
    Function DTR7()
    
    Dim rs As New ADODB.Recordset
    Dim cnn As New ADODB.Connection
    Dim x As Integer
    
            frmMain.Command2.Visible = True
            frmMain.Command1.Visible = False
            frmMain.cboCourse.Enabled = False
            frmMain.cboSemester.Enabled = False
            frmMain.cboYear.Enabled = False
    
    'Enabling Time,Room & Days Option
    For x = 0 To 6
         frmMain.Combo1(x).Enabled = True
         frmMain.Combo2(x).Enabled = True
         frmMain.Combo3(x).Enabled = True
    Next
    'Enabling Time,Room & Days Option
    
    'Time Connection
    If rs.State = adStateOpen Then rs.Close
           rs.Open "Select * from [Time]", cnn, adOpenKeyset, adLockOptimistic
        While rs.EOF <> True
            For x = 0 To 6
             frmMain.Combo1(x).AddItem rs.Fields("Time").Value
            Next x
         rs.MoveNext
        Wend
    'Time Connection
    
    'Room Connection
    If rs.State = adStateOpen Then rs.Close
           rs.Open "Select * from [ROOMS]", cnn, adOpenKeyset, adLockOptimistic
      While rs.EOF <> True
        For x = 0 To 6
             frmMain.Combo2(x).AddItem rs.Fields("ROOM").Value
        Next x
      rs.MoveNext
      Wend
    'Room Connection
    
    'Days Connection
    If rs.State = adStateOpen Then rs.Close
           rs.Open "Select * from [DAYS]", cnn, adOpenKeyset, adLockOptimistic
      While rs.EOF <> True
        For x = 0 To 6
             frmMain.Combo3(x).AddItem rs.Fields("DAYS").Value
        Next x
      rs.MoveNext
      Wend
    'Days Connection
    End Function
    the highlited part when i debug it is on the word "Function DRT7 ()"

    what seems to be a problem here,hope somebody can help me with this. thank you very much...
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by darrel
    Hello, i need you help, can someone whats the cause of getting an error of Expected function or variable, its like this i have a function code in a module and call it on my main form.. here my code:
    Code:
    Function DTR7()
    
    Dim rs As New ADODB.Recordset
    Dim cnn As New ADODB.Connection
    Dim x As Integer
    
            frmMain.Command2.Visible = True
            frmMain.Command1.Visible = False
            frmMain.cboCourse.Enabled = False
            frmMain.cboSemester.Enabled = False
            frmMain.cboYear.Enabled = False
    
    'Enabling Time,Room & Days Option
    For x = 0 To 6
         frmMain.Combo1(x).Enabled = True
         frmMain.Combo2(x).Enabled = True
         frmMain.Combo3(x).Enabled = True
    Next
    'Enabling Time,Room & Days Option
    
    'Time Connection
    If rs.State = adStateOpen Then rs.Close
           rs.Open "Select * from [Time]", cnn, adOpenKeyset, adLockOptimistic
        While rs.EOF <> True
            For x = 0 To 6
             frmMain.Combo1(x).AddItem rs.Fields("Time").Value
            Next x
         rs.MoveNext
        Wend
    'Time Connection
    
    'Room Connection
    If rs.State = adStateOpen Then rs.Close
           rs.Open "Select * from [ROOMS]", cnn, adOpenKeyset, adLockOptimistic
      While rs.EOF <> True
        For x = 0 To 6
             frmMain.Combo2(x).AddItem rs.Fields("ROOM").Value
        Next x
      rs.MoveNext
      Wend
    'Room Connection
    
    'Days Connection
    If rs.State = adStateOpen Then rs.Close
           rs.Open "Select * from [DAYS]", cnn, adOpenKeyset, adLockOptimistic
      While rs.EOF <> True
        For x = 0 To 6
             frmMain.Combo3(x).AddItem rs.Fields("DAYS").Value
        Next x
      rs.MoveNext
      Wend
    'Days Connection
    End Function
    the highlited part when i debug it is on the word "Function DRT7 ()"

    what seems to be a problem here,hope somebody can help me with this. thank you very much...
    In a previous post with this code, I meant to mention you have ROOMS and ROOM, perhaps that's where the problem is:

    Code:
    frmMain.Combo2(x).AddItem rs.Fields("ROOM").Value

    Comment

    Working...