Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    18

    Unanswered: Listbox and message box help

    I have a video store database under construction.

    I have a command button (cmd_open) and a listbox (listvideo) on my main form. The list box shows video_id, name, number available etc..

    I select a row from the listbox and click the command button to open a second form which shows all the fields and information relating to the row I selected in the listbox.

    One of the colums for each row in the listbox is "number_available". If the amount is "0" (no videos in stock) I need a message box to appear when I click the command button to inform me of this and stop the second form from opening (cancel event).

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you can talk to any of the columns in your listbox.
    they are indexed starting 0, 1, 2, 3, 4

    so....

    private sub cmd_open_Click()
    if me!listvideo.column(1) = 0 then 'or 2 or 3 or 4 or wherever it is
    msgbox "Sorry! No stock left", vbexclamation, "NO STOCK"
    else
    docmd.openform "whateverItIsCalled"
    endif

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jan 2005
    Posts
    18
    Cheers Izy your one helluva guy!!

    Id basically got exactly what you put, but I must have got some exclamation marks in the wrong place or something!

    Thanks Allot

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,422
    Provided Answers: 7
    private sub cmd_open_Click()
    if me!listvideo.column(1) = 0 then 'or 2 or 3 or 4 or wherever it is
    msgbox("Sorry! No stock left", vbexclamation, "NO STOCK")
    else
    docmd.openform "whateverItIsCalled"
    endif


    add ( ) the the msgbox


    why not change the query to only show vedio that you can only take out
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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