Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 23rd, 2009, 10:13 PM
talie talie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 talie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 9 sec
Reputation Power: 0
Red face Forms - Generating job number depending on numerous selections

Ok I will try keep this short, but I'm struggling!

I have customers and jobs. (1 to many)
Every job will have it's own job number but this then needs to be shared over the months depending on the following:
When raising a job, the user will select [Period] whether the maintenance is to be completed Annually, quarterly, monthly
User will then select the month that the maintenance commences.
Under that is a table of Jan through to Dec where the user inputs data (hours on site etc) and under each month is the job number

Each month will have the same job number but will be pre and post fixed from the selections above.
The problem I'm faced with is my code going to be huge, as the below code will have to be replicated for each month. Is there a way I can shorten this? A better way of coding it?

This code is for if january is selected only

If Me.Month_Commenced.Value = "Jan" Then
If Me.Period = "Quarterly" Then
Me.Janjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "1"
Me.Apjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "2"
Me.Juljob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "3"
Me.Octjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "4"
'along with resetting all other months to ""
Else
If Me.Period = "Annual" Then
Me.Janjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "1"
'along with setting all other months to ""
Else
If Me.Period = "Monthly" Then
Me.Janjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "1"
Me.Febjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "2"
Me.Marjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "3"
Me.Apjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "4"
Me.Mayjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "5"
Me.Junjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "6"
Me.Juljob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "7"
Me.Augjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "8"
Me.Septjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "9"
Me.Octjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "10"
Me.Novjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "11"
Me.Decjob_ = Me.Jobtypeprefix & Me.Autonumber & (Left$([Period], 1)) & "12"
End If
End If
End If
End If

Hope this makes sense. thanks in advance

Reply With Quote
  #2  
Old June 24th, 2009, 01:14 AM
June7 June7 is online now
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 497 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 h 22 m 20 sec
Reputation Power: 102
First problem I see is with the Monthly identifiers:
"M12" will sort before "M9", should use filler zeros, make it "M09". As for whether there is something better for the whole works, will have to study for a while. Might help to know why you feel this strucure necessary, how you will use the entity.

Last edited by June7 : June 24th, 2009 at 01:17 AM.

Reply With Quote
  #3  
Old June 24th, 2009, 10:30 AM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
Like June said, If you want to use the month as part of your job numbering system I'd really recommend you use a leading 0 for any single digit months. You'll find it easier to deal with. Secondly it looks to me like you want to store your data like this:

Code:
Customer   Jan   Feb   Mar   Apr   May   Jun --------> remaining months
Cust A     JN1   JN2   JN3   JN4   JN5   JN6 ------>
Cust B     JN1               JN2             ------>
Cust C           JN1                  JN2    ------>
Cust D     JN11  JN12  JN1   JN2   JN3   JN4 ------>


Where Customers A and D are monthly, B and C are quarterly
When you really probably should be storing the data like:

Code:
Customer   Month   JN
Cust A     1       JN1
Cust A     2       JN2
Cust A     3       JN3
(remaining cust A jobs)
Cust B     1       JN1
Cust B     4       JN2
(remaining cust B jobs)
Cust C     2       JN1
Cust C     5       JN2
(remaining cust C jobs)
etc


Storing your information the first way is a lot harder to deal with if you're searching for a particular job or really doing any sort of queries against this table, it would probably involve a lot of union queries.

The second way is pretty efficient in terms of searches and queries and overall will make your code a lot easier to run.

That being said here is an example to do what you want.
Comments on this post
June7 agrees: Expresses what troubled me about the data structure (sorry, won't let me assign point value!)
Attached Files
File Type: zip Talie.mdb.zip (47.2 KB, 11 views)
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #4  
Old June 29th, 2009, 08:22 PM
talie talie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 talie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 9 sec
Reputation Power: 0
ok I finally worked out that it was a db for vista version, so I finally managed to open it.

But yes it's near what I want, very clever!
I couldn't access the design view of the form or tables tho, not sure if it's protected?? Sorry I can't work bloody vista out!

Was after the code for it if that's ok

Thank you soooo much for your help too

Reply With Quote
  #5  
Old June 29th, 2009, 11:19 PM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
I didn't protect any of the content in the database. You should be able to get to the design of the tables even if it tells you you can't make modifications you should be able to get past that and see the design, just not modify them (if you have the data entry form open)

Reply With Quote
  #6  
Old June 30th, 2009, 03:22 AM
talie talie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 talie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 9 sec
Reputation Power: 0
Quote:
Originally Posted by rpeare
I didn't protect any of the content in the database. You should be able to get to the design of the tables even if it tells you you can't make modifications you should be able to get past that and see the design, just not modify them (if you have the data entry form open)


the design tabs are just greyed out no matter what I click on, it's really bizare. Is there anything else I can try??
Really sorry to be a pain about this, but it's spot on for what I need and have no idea how you programmed it

Thanks again

Reply With Quote
  #7  
Old July 1st, 2009, 02:06 PM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
I'll repost the database after I convert it to an older version of access. Should be sometime tomorrow. (thursday)

Reply With Quote
  #8  
Old July 2nd, 2009, 08:53 AM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
Ok here it is. In case I've botched the conversion the code behind the buttons is:

Code:
Option Compare Database

Private Sub Cmd_FillJobs_Click()

Dim sPeriod As String
Dim iMonth As Integer
Dim iGap As Integer
Dim sMonth As String
Dim sFieldName As String
Dim iIterations As Integer
Dim iNextMonth As Integer
Dim sNextField As String

sPeriod = Period
iMonth = Month_Commenced
'lookup the gap between jobs
iGap = DLookup("[MonthGap]", "Tbl_Periods", "[Period] = '" & Me.Period & "' ")
'lookup the label for the month chosen
sMonth = DLookup("[MonthName]", "Tbl_Months", "[MonthNum] = " & Me.Month_Commenced & " ")

'go to the first field that needs a job entered
sFieldName = sMonth & "job_"
DoCmd.GoToControl ("" & sFieldName & "")
Me.ActiveControl = Left(sPeriod, 1) & "01"

'Generate the number of jobs to be filled
iIterations = 12 / iGap

iNextMonth = iMonth

For iIterations = 1 To iIterations - 1
If iNextMonth + iGap > 12 Then
        iNextMonth = iNextMonth + iGap - 12
    Else
        iNextMonth = iNextMonth + iGap
    End If
    sNextField = DLookup("[Monthname]", "tbl_months", "[MonthNum] = " & iNextMonth & " ") & "Job_"
    DoCmd.GoToControl ("" & sNextField & "")
    Me.ActiveControl = Left(sPeriod, 1) & Right("0" & iIterations + 1, 2)

Next iIterations


End Sub


Private Sub Cmd_Clear_Click()

JanJob_ = Null
FebJob_ = Null
MarJob_ = Null
AprJob_ = Null
MayJob_ = Null
JunJob_ = Null
JulJob_ = Null
AugJob_ = Null
SepJob_ = Null
OctJob_ = Null
NovJob_ = Null
DecJob_ = Null
End Sub
Attached Files
File Type: zip Talie-2003.mdb.zip (25.9 KB, 7 views)

Reply With Quote
  #9  
Old July 12th, 2009, 09:03 PM
talie talie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 talie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 9 sec
Reputation Power: 0
fab! Thanks so much for your time on this I really appreciate it.

I will give it a go in the next few days and let you know how I get on

thanks again
Natalie

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Forms - Generating job number depending on numerous selections


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
Stay green...Green IT