Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Thanked 0 Times in 0 Posts

    If Else (Access 2000)

    I seem to be drowned in the EsleIf condition and cannot get out of it.Can somebody help me with setting
    the EndIf.. condition straight?
    All the separate functions are working OK so the problem lies with the correct distribution of the If conditions.
    Here is the tasks i have to perform:

    I have a form and and a list box called ListOrders. Above the listbox i have a command control.In the OnClick event
    of the command control i have to performn the following actions

    Prelinimary condition: If nothingfrom the list is chosen then Exit Sub

    If an ordedr from the list is chosen then i have to ask and correspondingly act as follows:

    1First question Delete? If yes, then the function Cancelorder is performed
    If the answer is no then i have to ask the following questions :

    2. Transact ? If the answer is yes, then the function Transact is performed
    if the answer is no then i must ask the question:

    2. Print ? shall i just open it in preview mode, or give the command to print

    Below is my failed attempt to build the code.
    I wull be very happy is someone helps me find the solution.

    Private Sub CmdOrders_Click()
    If IsNull(Me![list]) Then
    MsgBox " Please select Order first ! "
    Exit Sub
    Dim stLinkCriteria As String
    Dim stDocName As String
    stDocName = "Invoice"
    stLinkCriteria = "orderid = " & ListOrders
    Dim intPrint As Integer
    Dim intAnswer As Integer
    intAnswer = MsgBox(" Delete? ", vbQuestion + vbYesNo)
    If intAnswer = vbYes Then
    Application.Echo False

    intPrint = MsgBox(" Print? ", vbQuestion + vbYesNo)
    If intPrintAnswer = vbYes Then
    direct ' this function prints 4 copies
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
    End If
    End If
    DoCmd.Close acForm, Me.Name
    End Sub

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Melbourne, Australia
    Thanked 32 Times in 32 Posts

    Re: If Else (Access 2000)

    First you have the following instruction
    If intPrintAnswer = vbYes Then
    which should read
    If intPrint = vbYes Then

    Where is the code that runs the function Transact?

    FWIW I would have had an option box to drive this logic.

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Mt Macedon, Victoria, Australia
    Thanked 45 Times in 44 Posts

    Re: If Else (Access 2000)

    A few observations:
    * The Transact ? seems to be missing.
    *User can do one and only one of four things. This is better handled as a select statement rather than a series of if else statements. it is easier to get right.
    * Instead of asking a series of questions, put an option group on the form, so that the user can say just once what they want to do, rather.

Posting Permissions

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