Results 1 to 5 of 5

Thread: Why wrong?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    40

    Why wrong?

    Private Sub Voeg_nieuwe_oplossing_toe_Click()

    CurrentDb.Execute "INSERT INTO TblOplossingen (Oplossing) VALUES ('" & TypnieuweOplossing.Value & "')"

    IDMAX = "Select MAX ID from TblOplossingen"
    CurrentDb.Execute "INSERT INTO TblKruis (IDFout, IDOplossing) VALUES ('" & KiesFout.Value & "', '" & IDMAX.Value & "')"

    End Sub


    The IDMAX is the autonumberfield in a table.

    greetz

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Why wrong?

    Try..

    IDMAX = "Select MAX(ID) from TblOplossingen"

    or

    IDMAX = DMax("ID","TblOplossingen")
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    40

    Re: Why wrong?

    VBdebugger says the fault lies in:

    CurrentDb.Execute "INSERT INTO TblKruis (IDFout, IDOplossing) VALUES ('" & KiesFout.Value & "', '" & IDMAX.Value & "')"

    I would think instead of Value something else but i don't know what exactly.

    greetz

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Why wrong?

    "The IDMAX is the autonumberfield in a table." -- no it isn't.... it's a text string. You're setting it to a SELECT, but you never execute it or anything. Then in the very next line, you try to use like it's a recordset or something.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    40

    Re: Why wrong?

    Is it possible to add?

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