Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / December 2005

Tip: Looking for answers? Try searching our database.

Counter Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcelino Benitez - 15 Dec 2005 15:51 GMT
I running a work order application. I have a counter field that contains a
letter, julian date and a counter number. Ok I have an A, B, C, D, E, F, G, X,
R company. Ok when I start my date and select B I have a counter beggining on
number 1. Then if I select A first of the day in this company will give me 02
instead of 01. Why I don't know need some help. This is the code that I use.

Private Sub Company_AfterUpdate()
Dim count As Variant
Dim compdate As Variant
Dim JDate As Integer
Dim Ydate As Integer '
Dim t As Variant 'Counter variable

Me.Undo
Form.Requery
DoCmd.GoToRecord , , acLast 'Send the page to the last record
compdate = Text31
'MsgBox Text31

DoCmd.GoToRecord , , acNewRec

JDate = Format(Date, "y")
Ydate = Format(Date, "yy")

If JDate < 10 Then
tdate = Company & Ydate & "0" & "0" & JDate & "-" & "01"
End If

If JDate >= 10 Then
tdate = Company & Ydate & "0" & JDate & "-" & "01"
End If

If JDate > 99 Then
tdate = Company & Ydate & JDate & "-" & "01"
End If

'MsgBox [tdate]

If compdate > tdate Or compdate = tdate Then
t = Format(compdate, "!&&")
If t < 99 Then
t = t + 1
t = Format(t, "00")
End If

If JDate < 10 Then
WONum = Company & Ydate & "0" & "0" & JDate & "-" & t
End If

If JDate >= 10 Then
WONum = Company & Ydate & "0" & JDate & "-" & t
End If

If JDate > 99 Then
WONum = Company & Ydate & JDate & "-" & t
End If
Else
WONum = tdate

End If

DoCmd.GoToControl "Model"

End Sub
Rob Oldfield - 15 Dec 2005 20:44 GMT
Your best plan is going to be to step through your code to see where it's
going wrong.  To do that...

Go to the code window and right click the DoCmd.GoToRecord , , acLast line.
Choose Toggle, Breakpoint.  That line will be highlighted.
Now close the code window and switch to form view.  Update the company and
it should run through the code and stop when it reaches the breakpoint you
just set.
Hit F8.  It will move to the next line to process.
Hit F8 again... etc, etc.
You can hit F5 and code will continue normally at any time (but will halt
again the next time it reaches a breakpoint), you can also wave the mouse at
any variable to see what it is currently set as.

Hopefully, you should be able to use this to see where the code is taking a
different path from what you expect, and to identify which variable is
causing it to take that wrong path.

> I running a work order application. I have a counter field that contains a
> letter, julian date and a counter number. Ok I have an A, B, C, D, E, F, G, X,
[quoted text clipped - 60 lines]
>
> End Sub
Marcelino Benitez - 16 Dec 2005 20:39 GMT
Hey Rob can I send you my application and that way you can check please.  My
email is benitezm@soar.army.mil. Thanks in advance.

Marcelino
>Your best plan is going to be to step through your code to see where it's
>going wrong.  To do that...
[quoted text clipped - 19 lines]
>>
>> End Sub
Rob Oldfield - 16 Dec 2005 22:05 GMT
That's not a road I want to go down I'm afraid.  What does the debug thing
give you?

> Hey Rob can I send you my application and that way you can check please.  My
> email is benitezm@soar.army.mil. Thanks in advance.
[quoted text clipped - 23 lines]
> >>
> >> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.