Results 1 to 16 of 16

Thread: it was working great till i tried to compile...

  1. #1

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201

    it was working great till i tried to compile...

    hi guys ..

    this little bit of code worked great till i tried to compile it - now it bugs out on variable not defined...can any one help?

    VB Code:
    1. Private Sub CmdWriteCDGDIR_Click()
    2.  
    3. Set gorsgetkaraoke = New ADODB.Recordset
    4. Set gorsgetkaraoke = goEnv.getkaraoke(goEnv.Cnn, CLng(songnum), Trim(singer), Trim(song), Trim(Path))
    5.  
    6. Open "C:\directory.txt" For Output As #1
    7. gorsgetkaraoke.MoveFirst
    8. While Not gorsgetkaraoke.EOF
    9.     Print #1, gorsgetkaraoke!ID & Chr$(44) & Chr$(34) & gorsgetkaraoke!singer & Chr$(34) & Chr$(44) & Chr$(34) & gorsgetkaraoke!song&; Chr$(34) & Chr$(44) & Chr$(34) & 0 & Chr$(34) & Chr$(44) & Chr$(34) & gorsgetkaraoke!Path & Chr$(34) ' & Chr$(44) & Chr$(34) & "K" & Chr$(34)
    10.    
    11.     gorsgetkaraoke.MoveNext
    12. Wend
    13. Close
    14.  
    15. End Sub

    bugs out on the below line at the clng (songnum) which is an autonumber..

    VB Code:
    1. goEnv.getkaraoke(goEnv.Cnn, CLng(songnum), Trim(singer), Trim(song), Trim(Path))


    heres the sql statement :

    VB Code:
    1. Public Function getkaraoke(ByRef oCnn As ADODB.Connection, ByVal songnum As Long, ByVal singer As String, ByVal song As String, ByVal Path As String) As ADODB.Recordset
    2.  
    3.    On Error GoTo No_Bugs
    4.    
    5.     Dim oRs As ADODB.Recordset
    6.     Dim ssql As String
    7.    
    8.     ssql = "SELECT *"
    9.     ssql = ssql & " FROM"
    10.     ssql = ssql & " sunfly"
    11.    
    12.  
    13.     Set oRs = New ADODB.Recordset
    14.     oRs.Open ssql, goEnv.Cnn, adOpenKeyset, adLockOptimistic, adCmdText
    15.     Set getkaraoke = oRs
    16.     Set oRs = Nothing
    17.     Exit Function
    18.  
    19.    
    20. No_Bugs:
    21.    
    22.     MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation
    23.  
    24. End Function


    this is total pants - it takes me all my time to write code that works then the compiler wastes it for me!

    davie.

    (i know its my fault somehow , but its nice to lay the blame somewhere else for a short while)

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    I'm guessing that an "autonumber" is a control. Use the control's value property, whatever that might be.

    Like in a textbox, the value property is "Text". Try using that instead of an implicit variable.
    Please rate my post.

  3. #3

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    shawn how do i find the controls value property?

  4. #4

  5. #5
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    fenster - what control are you using? Someone here would probably be able to tell you. I don't have access to VB so I'm not of much help in that area.

    Martin - I'm assuming he is using OE since he's getting an error regarding a variable not being dimensioned. If he wasn't using OE the app would compile but not function.
    Please rate my post.

  6. #6

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    i have this line in the modstartup.bas

    VB Code:
    1. Public gorsgetkaraoke As ADODB.Recordset

    is this what u mean martin?

    I also have sp5 - on windows xp - im sure my references i need are all enabled.


    is there even a way to return it to its working state before i tried to compile it ?- that would be a decent solution for me
    Last edited by fenster; Mar 2nd, 2004 at 07:39 PM.

  7. #7
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    What is songnum? A control? A public variable?

    Option Explicit is a command given to VB to not let you use any variables that have not been declared. This stops variable name typos when you're coding.
    Please rate my post.

  8. #8

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    its an autonumber field in the db i changed it from ID just in case it was reserved..

    it is a long integer (field size)

    the code retrieves songnumber,singer,song and path of file then the next bit formats it the way i want and dumps to txt file.

  9. #9
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    There is no way this coding ever worked the way it is written.

    First of all, Function getkaraoke asks for a list of parameters but they're never used. So you could change the protocall for Function getkaraoke from

    VB Code:
    1. Public Function getkaraoke(ByRef oCnn As ADODB.Connection, ByVal songnum As Long, ByVal singer As String, ByVal song As String, ByVal Path As String) As ADODB.Recordset
    to
    VB Code:
    1. Public Function getkaraoke As ADODB.Recordset

    THEN, since getkaraoke does not accept any parameters, you can change the way you call it from

    VB Code:
    1. Set gorsgetkaraoke = goEnv.getkaraoke(goEnv.Cnn, CLng(songnum), Trim(singer), Trim(song), Trim(Path))
    to
    VB Code:
    1. Set gorsgetkaraoke = goEnv.getkaraoke

    Try that.
    Please rate my post.

  10. #10

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    shawn , ill try ur suggestions - maybe then it will compile..

    i cant begin to understand ur knowledge of VB , and as i clearly state (check avatar for proof) im a total newbie.

    but the code DID work.

    and its working again.

    i simply started a new project and copied/pasted all code into a new form/module and class module - basically replicating the project.

    i can zip it up and stick it here if u want to see.

    it would be good to have it an .exe but if not i can alter the code and run it across LAN (the folder i want is on another PC.)

    Thanks for ur time - u 2 martin....

    davie.

  11. #11
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    So you got your coding working without making any changes? That's different. I wouldn't mind looking at the project as a whole if it's not an issue. Just to see where I slipped up.
    Please rate my post.

  12. #12

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    the code always worked - it stopped working after i tried to compile it.

    i clearly stated that in my post.


    v1. after compile - with the variable error

    v2 after made new project ,copied code in,but no attempt to compile - so it works fine.


    same code in both.



    davie.
    Attached Files Attached Files

  13. #13

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    and the other.......
    Attached Files Attached Files

  14. #14

  15. #15

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    sorry martin - u into this also
    Attached Files Attached Files

  16. #16

    Thread Starter
    Addicted Member fenster's Avatar
    Join Date
    Apr 2003
    Location
    Glasgow,Scotland
    Posts
    201
    these files i alredy used for another project - there may be some dead code lying in them - the karaoke thing was a util to use once only - so it may be a bit messy ...
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width