Results 1 to 5 of 5

Thread: Converting problems

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    3

    Converting problems

    Hi
    Can some one tell me if it is a lot of work to convert vba code (Access 2.0) to vba code (A2003). I get problems with the vba code when I tried to convert it. I'm a newbie in VBA coding.

    Thanks

    Rune

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    3

    Re: Converting problems

    For Example i get an error message for the 3. row in this code when I convert from A 2.0 to A 2003
    Function SetCaption()
    Dim hWnd%
    hWnd% = FindWindow%("OMain", 0&)
    Call SetWindowText(hWnd%, idsAPPNAME)
    End Function

    Maybe its a problem behind this problem, but the first error message is that one.
    Some advise?

    Rune

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Converting problems

    Access 2.0 was designed for 16 bit Windows 3.1. Since then all of the core DLLs changed so did all of the functions/subs they expose.
    In your case you need to declare variable as Long. Also api function declarations are different - instead of Integers they return Long types as well as all of the arguments that used to be Integers must be Long.
    VB Code:
    1. Private Declare Function SetWindowText Lib "user32" _
    2.     Alias "SetWindowTextA" (ByVal hwnd As Long, _
    3.     ByVal lpString As String) As Long
    4.  
    5. Private Declare Function FindWindow Lib "user32" _
    6.     Alias "FindWindowA" (ByVal lpClassName As String, _
    7.     ByVal lpWindowName As String) As Long
    8.  
    9. Private Function SetCaption()
    10. Dim hWnd [B]As Long[/B]
    11.  
    12.     hWnd = FindWindow("OMain", 0&)
    13.     Call SetWindowText(hWnd, idsAPPNAME)
    14.  
    15. End Function
    Note: % is the shortcut for Integer and Long is the &. Better way is to use the "As ..." when declaring variables.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    3

    Re: Converting problems

    Thanks Rhinobull

    Another error message occured now. I know it could be difficult with so little information.
    Can someone see if it is something I need to do with this code to make it work in access 2003. The vba code is made for access 2.0.

    Private Sub lstMeny_Click()
    lstMeny.StatusBarText = DLookup("[StatusBarTxt]", "Q_SYS_Bld_Hovedmeny", "[FullName]= '" & Forms![F_Bld_HOVEDMENY]![lstMeny] & "'")
    End Sub

    This error message came when I click a button on the main menu(Hovedmeny) to open a form.

    Thanks again I'm still a newbie

    Best regards
    Rune

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