Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 27th, 2010, 08:51 AM
Authorized User
 
Join Date: Dec 2003
Location: Vashi, Navi Mumbai, Maharashtra, India.
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default Booking number help

[FONT='Verdana','sans-serif']Hi,

I have an Access form linked to a table where the key in the table is an autonumber field. My table field is sno(autonumber,PK), name, rdate, order_number now my problems is When adding a new record to the table using the form I want insert into order_number field if rade is now() e.g. “A +sno” like “A001,A002,A003….” next day adding a new record I want from starting like “A001….”
[/FONT]
__________________
Mohamed Mohiddin
Officer

Last edited by mohiddin52; May 5th, 2010 at 10:32 AM..
Reply With Quote
  #2 (permalink)  
Old May 5th, 2010, 10:37 AM
Authorized User
 
Join Date: Dec 2003
Location: Vashi, Navi Mumbai, Maharashtra, India.
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default Booking number

I have an Access form linked to a table where the key in the table is an autonumber field. My table field is sno(autonumber,PK), name, rdate, order_number now my problems is When adding a new record to the table using the form I want insert into order_number field if rade is now() e.g. “A +sno” like “A001,A002,A003….” next day adding a new record I want from starting like “A001….”
__________________
Mohamed Mohiddin
Officer
Reply With Quote
  #3 (permalink)  
Old May 14th, 2010, 11:11 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

I understand what it is you want, but my advice is do NOT use the autonumber field "sno" for anythying. Autonumbers are generated by the computer and only have meaning behind the scenes to link a primary key to a foreign key. Autonumbers should not be used in calculations or concatenations for anything.

That said, if you want to use an order number that starts at no. 1 each day, that's not hard to do. I assume that you have one table with the companies and their info, including an autonumber for each record, say "sno." I also assume you have a second table for orders, e.g. "Orders", where you have a foreign key "sno" that links many orders to each company via "sno." In this order table you have a date the order was placed.called "rdate."

You can do something like this for the order number as you enter them into the second table via a subform. Note that Now() has a time associated with it. If you don't care what time it is, use Date().

Code:
If DCount("[sno]","Orders","[sno] = " & Me.sno & " And [RDate] = #" & Date() & "#") = 0 Then
    'There are no orders for sno today.
    Me.Order_Number = "A001"
Else
    'There are orders existing for today for sno.
    Me.Order_Number = "A" & CInt(Right(DMax("[Order_Number]","Orders","[Sno] = " & Me.sno & " And [RDate] = #" & Date() & "#"), 3)) + 1
End If
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 12 October 30th, 2011 07:24 AM
How to add a line number/Row number- need to use it for page breaks naijacoder XSLT 7 September 27th, 2009 09:42 PM
Appointment Booking KDSTECH BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 11 May 29th, 2008 12:46 AM
booking form LITOTES PHP How-To 2 June 4th, 2003 03:46 AM



All times are GMT -4. The time now is 05:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.