Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function depending on query (Acces 2000)

    I have a function that imports tables and appends them.I want this function to be executed only when a field is true, in my case the field Orders.Check in the following sql :

    SELECT Orders1.orderid, Orders1.Check
    FROM Orders1;

    The function is called TSave.How should i call the function only when the field Check is True ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function depending on query (Acces 2000)

    Your SQL statement only returns records, it doesn't append them to another table.

    Do you mean

    SELECT Orders1.orderid, Orders1.Check
    FROM Orders1
    WHERE Orders1.Check = True

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

    Re: Function depending on query (Acces 2000)

    This query will I assume have lots of records, and in some of them orders1.Check will be true and in others it will be false. Is that right?

    If that is th case then you need to have a form bound to the query and check the value of check in the oncurrent event.
    Regards
    John



  4. #4
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function depending on query (Acces 2000)

    Thank you both of you for your clever questions. In order to avoid the possibility to have other records with check = true, all the previous records with check = true are already deleted.I have to differentiate however between check = True and check = False and to carry out the function only when Check = true.
    How can i construct the If Clause in my function ?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function depending on query (Acces 2000)

    It is not clear how and where you are calling the function, and what the function does. You only posted an SQL statement that doesn't "do" anything.

    Please provide a clear and complete description of the function and of how and where you want to use it.

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

    Re: Function depending on query (Acces 2000)

    If you save this as a saved query, qryChecktrue

    SELECT Orders1.orderid, Orders1.Check
    FROM Orders1
    WHERE Orders1.Check = True

    then you check if Check is true in any records using

    if Dcount("*","qryCheckTrue")> 0 then
    execute the function
    otherwise
    don't
    end if
    Regards
    John



  7. #7
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function depending on query (Acces 2000)

    Thank you. I am sending to you the function :

    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase(GPath, dbDriverComplete, False, "; PWD=" & strPassword)
    DoCmd.TransferDatabase acLink, "Microsoft Access", GPath, acTable, "products", "products"
    DoCmd.TransferDatabase acLink, "Microsoft Access", GPath, acTable, "orders", "orders"
    DoCmd.TransferDatabase acLink, "Microsoft Access", GPath, acTable, "order details", "order details"
    DoCmd.TransferDatabase acLink, "Microsoft Access", GPath, acTable, "customers", "customers"
    Function AppendOrders ' the function to be executed only when the field Check in the table orders is set to true
    Function AppendProducts ' the function is always executed
    Function SendTheObjectstoTheActsDatabase
    DoCmd.Quit

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function depending on query (Acces 2000)

    Function AppendOrders is not a valid instruction. Do you mean Call AppendOrders ?

    As John also indicated, you cannot say "when the field Check in the table orders is set to true". Since the table can have multiple records, this doesn't make sense.

  9. #9
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function depending on query (Acces 2000)

    Yes,i mean Call AppendOrders. This is my function.John is right, but i have not such a problem since the table orders1 consists of only one record.It remains only to append this record to the table orders which is a full table.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function depending on query (Acces 2000)

    If there is only one record, you could use
    <code>
    If DLookup("Check", "Orders1") = True Then
    ...
    End If</code>

  11. #11
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function depending on query (Acces 2000)

    That will do for me perfectly.Thanks !

Posting Permissions

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