Load form parsing errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rbudnikas
    New Member
    • Jan 2007
    • 2

    Load form parsing errors

    Hey Ronald

    Thanks for the response. Could you look at my form_load and give me advice. I keep getting a syntax error and i think i am missing something obvious

    Dim conn As New ADODB.Connectio n
    Dim rs As New Recordset
    Set conn = New ADODB.Connectio n
    Set rs = New Recordset
    'On Error GoTo Err
    conn.Open "DRIVER={My SQL ODBC 3.51 Driver};SERVER= l7a.info;Port=3 306;DATABASE=** **;UID=******;P WD=****;OPTION= 16427"
    rs.Open "Select * from `storloc`", conn
    rs.MoveNext
    'heres the code i added
    Do Until rs.EOF = True
    Combo1.AddItem rs.Fields("city ").Value
    rs.MoveNext
    'end of new code
    If rs.EOF = True Then
    GoTo Done
    End If
    Loop
    Done:
    rs.Close
    conn.Close

    Originally posted by ronverdonk
    Use the SELECT DISTINCT col_name FROM ..etc...in your query.

    Ronald :cool:
    Last edited by rbudnikas; Jan 19 '07, 02:13 AM. Reason: remove information
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is a typical VB question. Therefore I'll split this thread from this post on and move that to the VB forum with the title "Load form parsing errors". Good luck.

    Ronald :cool:

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by rbudnikas
      Thanks for the response. Could you look at my form_load and give me advice. I keep getting a syntax error and i think i am missing something obvious
      You weren't very specific about the error. However, one thing I found when I copied your code is that in the SELECT string, the single quotes... well, aren't single quotes. They look as though they may have been converted by MS Word's "smart quotes" or something similar.

      Putting CODE tags around things makes this kind of thing easier to spot...
      Code:
      Dim conn As New ADODB.Connection
      Dim rs As New Recordset
      Set conn = New ADODB.Connection
      Set rs = New Recordset
      'On Error GoTo Err
      conn.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=l7a.info;Port=3306;DATABASE=****;UID=******;PWD=****;OPTION=16427"
      rs.Open "Select * from `storloc`", conn
      rs.MoveNext
      'heres the code i added
      Do Until rs.EOF = True
        Combo1.AddItem rs.Fields("city").Value
        rs.MoveNext
        'end of new code
        If rs.EOF = True Then
      [B]    [U]' GoTo Done[/U]
          [U]Exit Do[/U][/B]
        End If
      Loop
      [B][U]' Done:[/U][/B]
      rs.Close
      conn.Close
      Um... come to think of it, why does your table (or query) name have single quotes around it, anyway? And why are you skipping the first record? (Or did I misunderstand the point of the MoveNext?)

      (Note, I changed the GoTo to Exit Do and removed the Done label. Many programmers will scream if they see a GoTo statement.)

      Comment

      Working...