?
Solved

Adding 30 mins onto a 24hr time & displaying print details when form revisited

Posted on 2003-03-25
3
Medium Priority
?
130 Views
Last Modified: 2012-05-04
How do I add 30 mins onto 24hr time?

The following code works to display information used by print statements, but whenever I go to a different form and return to this form the printed information doesn't appear, but works ok if I re-start the program. Do you have any suggestions?
 
Private Sub Form_Load()
frmMaresToBeScanned.Refresh
frmMaresToBeScanned.Show

'Get Todays date
Dim TodayDate As Date
TodayDate = Format(Date, "dd/mm/yyyy")

'Print the details on the form
frmMaresToBeScanned.ForeColor = vbWhite
frmMaresToBeScanned.Print ""
frmMaresToBeScanned.Print ""
frmMaresToBeScanned.Print ""
frmMaresToBeScanned.Print ""
frmMaresToBeScanned.Print ""

frmMaresToBeScanned.Print Tab(40); "Todays Date:", TodayDate
frmMaresToBeScanned.Print Tab(40); "****************"
frmMaresToBeScanned.Print ""
frmMaresToBeScanned.Print ""
frmMaresToBeScanned.Print Tab(40); "Scan Number"; Tab(63); "Vet Number"; Tab(85); "Mare Number"
frmMaresToBeScanned.Print Tab(40); "***************"; Tab(63); "*************"; Tab(85); "****************"
frmMaresToBeScanned.Print ""

' Search and display mares to be scanned today
Dim ScanNo As Integer
Dim VetNo As Integer
Dim MareNo As Integer

frmMainMenu.datScan.Recordset.MoveFirst
   
Do Until frmMainMenu.datScan.Recordset.EOF
    If (frmMainMenu.datScan.Recordset.Fields("DateOfScan") = TodayDate) Then
        ScanNo = frmMainMenu.txtScanNo.Text
        VetNo = frmMainMenu.txtVetNo.Text
        MareNo = frmMainMenu.txtMareNo.Text
       
        frmMaresToBeScanned.Print Tab(40); ScanNo; Tab(63); VetNo; Tab(85); MareNo
    End If
    frmMainMenu.datScan.Recordset.MoveNext
Loop
   
End Sub
0
Comment
Question by:Lucy168
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8201914
Try DateAdd function..
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 120 total points
ID: 8201965
Hi Lucy168,

Indeed, dateadd is one part:

NewTime = DateAdd("n",30,OldTime)

You also need to set the .autoredraw property of the form to true before using Print on the form. This will preserve your print statements when you move to another form and back again.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0
 

Author Comment

by:Lucy168
ID: 8205302
This works but I cant get the time to be in (hh/mm) instead it is in (hh/mm/ss). How do I get rid of the seconds?

I also Can’t get it to leave a 1hr break, between 13:00 and 14:00, instead if just executes the first If statement: If (Not NewTime = DateAdd("n", 30, BeforeDinnerTime)) Then
OldTime = NewTime
NewTime = DateAdd("n", 30, OldTime)
Time = NewTime

The code used is shown below:

Dim NewTime As Date
Dim OldTime As Date
NewTime = "08:30"

Dim BeforeDinnerTime As Date
Dim AfterDinnerTime As Date
BeforeDinnerTime = "12:30"
AfterDinnerTime = "13:30"

Dim Time As String
Dim MareStatusNo As Integer
Dim MareNo As Integer
Dim MareFieldNo As String
Dim StallionNo As Integer
Dim FirstDateServed As String
Dim ArrivalDate As Date
Dim MareFinishedBeingServed As String
Dim MareNotToBeServiced As String

frmMainMenu.datProcessStatus.Recordset.MoveFirst
   
Do Until frmMainMenu.datProcessStatus.Recordset.EOF
    If (Not frmMainMenu.datProcessStatus.Recordset.Fields("ArrivalDate") = "") And (frmMainMenu.datProcessStatus.Recordset.Fields("MareFinishedBeingServed") = "No") Then
         If (Not NewTime = DateAdd("n", 30, BeforeDinnerTime)) Then
            OldTime = NewTime
            NewTime = DateAdd("n", 30, OldTime)
            Time = NewTime
        ElseIf (NewTime = DateAdd("n", 30, BeforeDinnerTime)) Then
            NewTime = DateAdd("n", 30, AfterDinnerTime)
            Time = NewTime
        End If
            MareStatusNo = frmMainMenu.txtProcessStatusNo.Text
            MareNo = frmMainMenu.txtMareNum.Text
            MareFieldNo = frmMainMenu.txtMareFieldNo.Text
            StallionNo = frmMainMenu.txtStallionNo.Text
            FirstDateServed = frmMainMenu.txtFDServed.Text
            frmMaresToBeServiced.Print Tab(40); Time; Tab(47); MareStatusNo; Tab(64); MareNo; Tab(73); MareFieldNo; Tab(88); StallionNo; Tab(101); FirstDateServed;
    End If
    frmMainMenu.datProcessStatus.Recordset.MoveNext
Loop
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question