Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Error if record not found

Discussion in 'Information Technology' started by Les, Jul 28, 2006.

  1. Les

    Les
    Expand Collapse
    Guest

    Hello all, firstly i am not a programmer but a dabbler !! My problem is
    that i have a query with a field that requires the user to input the
    supplier number to fetch the correct record, and then a form with all
    the supplier details is printed. However if the user types in an
    incorrect number then it just prints a blank form and i would like an
    error message to be displayed instead.
    Could somebody please help me with code or a suggestion how to do it.

    thank you & best regards,

    Les Stout
     
  2. Loading...


  3. BruceM

    BruceM
    Expand Collapse
    Guest

    Are you having the user work directly with the query? If so, you would do
    much better with a form. To get started with a form without having to
    design it from scratch, click to select the query in the database window
    (the window that very likely is the first thing you see when you open a
    database, with listing of tables, queries, forms, etc.). With the query
    name selected (highlighted), click the AutoForm icon on the toolbar (or
    click Insert > AutoForm). Switch to design view and format as you choose.

    You may do better to use a combo box to select the supplier by name rather
    than by typing a number. The combo box wizard can take care of that.

    Reports have a No Data event that can be used if you are searching for
    records that may or may not be included within certain criteria. For
    instance, if you are searching for unpaid invoices for last month, but there
    are none, the report contains no data. If this is the situation I can
    provide more details.

    For most purposes, if you want to print you use a report. Forms can be
    printed, but reports are best in most situations.

    "Les" <les.stout@bmw.co.za> wrote in message
    news:1148567403.850028.291480@y43g2000cwc.googlegroups.com...
    > Hello all, firstly i am not a programmer but a dabbler !! My problem is
    > that i have a query with a field that requires the user to input the
    > supplier number to fetch the correct record, and then a form with all
    > the supplier details is printed. However if the user types in an
    > incorrect number then it just prints a blank form and i would like an
    > error message to be displayed instead.
    > Could somebody please help me with code or a suggestion how to do it.
    >
    > thank you & best regards,
    >
    > Les Stout
    >
     
  4. Les

    Les
    Expand Collapse
    Guest

    Hi Bruce, i have got a report based on the query that i made but it did
    not want to work correctly. It is the query criteria that requests the
    number with [Please insert number], the number gets inserted and the
    report is then opened and printed with a macro. What i want to happen
    is that they can look at there suppliers on a form, that has sub forms
    on,using a drop down but if the information is not correct then he must
    print out a document showing the information so that he can change it
    to give to an administrator to update.But my problem is the error if it
    does not find the input number.
     
  5. BruceM

    BruceM
    Expand Collapse
    Guest

    How are you opening the report? What do you mean "printed with a macro"?
    What is this form on which the suppliers appear? What are the subforms? If
    users are selecting the supplier from a combo box, what information may need
    to change? Do you want to select a supplier's record, then print out that
    supplier's information?

    I know this is a lot of questions, but I can only guess what you are trying
    to do.

    The short answer for a report with no data is to open the report's
    properties. To do this, in report design view click View > Properties.
    Click the Events tab. Next to On No Data click the three dots. Click Code
    Builder, OK. Enter the following between Private Sub and End Sub

    msgbox "No records"
    Cancel = True

    "Les" <les.stout@bmw.co.za> wrote in message
    news:1148573969.156725.247490@g10g2000cwb.googlegroups.com...
    > Hi Bruce, i have got a report based on the query that i made but it did
    > not want to work correctly. It is the query criteria that requests the
    > number with [Please insert number], the number gets inserted and the
    > report is then opened and printed with a macro. What i want to happen
    > is that they can look at there suppliers on a form, that has sub forms
    > on,using a drop down but if the information is not correct then he must
    > print out a document showing the information so that he can change it
    > to give to an administrator to update.But my problem is the error if it
    > does not find the input number.
    >
     

Share This Page