Visual Basic 6 & Access 2000


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Select Where

    How do we point to a VB6 public variable from within a SELECT statement?

    Set rsProfile = dbProfile.OpenRecordset("SELECT * FROM tblProfile WHERE ptrMenu = ptrCurrentMenu")

    Both ptrMenu (primary key) and ptrCurrentMenu are defined as LONG, but it only works when I hardcode a 1 instead of ptrCurrentMenu.

    Robert


    EDIT: Found it in Programmer's Heaven, thanks Steve: ("SELECT * FROM tblProfile WHERE ptrMenu = " & ptrCurrentMenu)
    Last edited by Demon; - 29th August 2006 at 22:51.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Null not a null

    I would have expected this IF statement to trap a Null, but apparently it doesn't work that way. The execution fell right down to the ELSE and executes the next statement. Any idea how to do make it work?

    Robert
    Attached Images Attached Images  
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Demon
    I would have expected this IF statement to trap a Null, but apparently it doesn't work that way. The execution fell right down to the ELSE and executes the next statement. Any idea how to do make it work?

    Robert
    Try "vbNull" instead. (Cant test as I dont have VB on this machine!)
    Last edited by Demon; - 4th October 2016 at 16:56.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  4. #4
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Use the Visual Basic function IsNull().

    Best regards,

    Luciano

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default

    Thank you!

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Reading value of Autonum key after insert

    -----------------------------------------------------
    Dim ptrProfile as Long

    Dim dbProfile As Database
    Set dbProfile = OpenDatabase(strPath & "\" & strFilename)
    Dim rsProfile As Recordset
    Set rsProfile = dbProfile.OpenRecordset("tblProfile")

    rsProfile.AddNew
    rsProfile!Description = "bla bla bla"
    rsProfile.Update

    ptrProfile = rsProfile!ptrMenu <-- Primary key, Autonum
    -----------------------------------------------------

    According to one of my Access books this should place the new key into ptrProfile but it doesn't.

    Am I supposed to set special parameters for update? Like UpdateNow or something like that? I see references to Cursor Types and Record Locks but I can't figure how to use them.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Try that.

    Best regards,

    Luciano

    Code:
    rsProfile.AddNew
    rsProfile!Description = "bla bla bla"
    ptrProfile = rsProfile!ptrMenu 
    rsProfile.Update
    Last edited by Luciano; - 31st August 2006 at 20:02.

Similar Threads

  1. Replies: 5
    Last Post: - 24th August 2006, 21:59
  2. Visual Basic 6 question
    By Christopher4187 in forum Off Topic
    Replies: 5
    Last Post: - 3rd July 2006, 13:06
  3. Visual Basic 6 and Pic com
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th September 2005, 05:21
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. '877 and Visual Basic 6
    By Tomas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th March 2004, 02:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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