Results 1 to 5 of 5
  1. #1
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55

    Set default value in text box

    Hi I have an attractions table linked to OrderDetails (which will contain the details of how many tickets and type of tickets). Once a person has selected the attraction they can then choose the number and type of tickets they want. The issue I have is that the OrderDetails is then linked to the Order table (which shows the totalprice, deposit required etc for all tickets chosen).

    The best way I can think to allocate an order number in the OrderDetails table is to set the default value of the OrderNo field in the Order details to the next OrderNo from the Order table. I have tried setting the default value to MAX OrderNo +1 using all sorts of SELECT statements but I keep getting syntax errors. Is it possible to do this? Can anyone help please?


    Thank you in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Is it too late to change it to autonumber? This is the BEST way to do incrementing values.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    DefaultValue property cannot be set to an SQL statement. It can use DMax() domain aggregate function. But why would you calculate an order number in order details that is not already in the Orders table?

    Have you considered a form/subform arrangement?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Maybe I have set up the tables wrong. My attractions links to my order details because there can be many attractions within the order (attraction, ticket type, no of tickets etc for several attractions). Then the orderdetails table links to the order table (which shows the total amount payable, the deposit etc). So when I enter order details I somehow have to allocate an OrderID first from the Order table. can't see how I could link my attractions straight to the order table because I need to have multiple attractions within the order. I hope this makes sense?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Usual arrangement for order and order details is:

    tblOrders
    OrderID (PK)
    OrderDate
    CustomerID (FK)

    tblOrderDetails
    ID
    OrderID (FK)
    ProductID (FK)
    Quantity

    Maybe ProductID would be FK for the ID from tblAttractions?

    Total amount due on an order should be calculated from tblOrderDetails records, not saved into tblOrders.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Default Hyperlink Text
    By mrmims in forum Forms
    Replies: 4
    Last Post: 07-07-2015, 04:17 PM
  2. Replies: 12
    Last Post: 03-01-2015, 01:36 PM
  3. Combo Box Default Value / Help Text,
    By jerem in forum Forms
    Replies: 3
    Last Post: 07-16-2014, 06:29 PM
  4. create default rich text in text box
    By enemydr in forum Forms
    Replies: 7
    Last Post: 02-19-2014, 09:38 PM
  5. Background Text (Not Default)
    By Douglas Post in forum Forms
    Replies: 1
    Last Post: 02-16-2012, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums