Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Date Buttons < Top X | Load Faster >
Back to Date Buttons    Comments List
ApptBtn Upload Images   Link   Email  
Rami Kanawati     
2 years ago
Hi ,

How we can Add time for Apptbtn

I watch this video but appointment it should having time not only date

https://599cd.com/blog/display-article.asp?ID=2513
Adam Schwanz             
2 years ago
Instead of Date() do Now()
Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago
Thanks for replay

I changed to now and it is now only change the second
Adam Schwanz             
2 years ago
So is the problem solved? If not review below, if it doesn't help, rephrase the issue please.

Date() Returns just the date. 12/9/2022
Time() Returns just the time. 3:30:38 PM
Now() Returns the date and the time. 12/9/2022 3:30:38
If you want to display it differently you will need to format it. Like Format(Now(), "mm/dd/yyyy hh:nn")
Rami Kanawati OP     
2 years ago
Hi Adam ,

This it will return only the time but when we talk about Clinic Appointment and you need to book the date and the time for patient
This will be help less
let me explain my need

I need to book date and time for patient for example
Appointment for patient1 ( Mon-  11-Dec-2022 ) Time ( 15:00 ) or 3:00 PM
Appointment for patient2 ( Mon-  11-Dec-2022 ) Time ( 15:30 ) or 3:30 PM
Appointment for patient3 ( Mon-  11-Dec-2022 ) Time ( 15:45 ) or 3:45 PM
etc
however also if there is book for any patient the program will give me only available date for patient 4 and the date and time should not be overlap between Patients

Hope it is more clear now for you

Thanks
Kevin Robertson           
2 years ago
Next Appointment
Appointments
Format

Richard also has 2 classes which deal with dates and times:
Access Expert 27
Access Expert 28

Also: Access DateTime Seminar
Rami Kanawati OP     
2 years ago
Thanks Kevin

I watched All this videos right now
But unfortunately, all these videos are not solved my concern my requirement is very small I don't think this need high level of developer I only want to use that option at my clinic that is all
Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago
Any One can help please why i got this erorr
Rami Kanawati OP     
2 years ago
here with the full code


code
Option Compare Database

Private Sub cboTime_Enter()
    Dim i As Date, n As Integer, oRS As DAO.Recordset, sSQL As String
    Dim dLowerbreak As Date, dUpperBreak As Date, dDuration As Date
    Dim dLowerPrecision As Date, dUpperPrecision As Date
    CboTime.RowSourceType = "Value List"
    CboTime.RowSource = ""
    If IsNull(Start) Then Exit Sub Else i = Start
    If Me.NewRecord = True Then
        DoCmd.RunCommand acCmdSaveRecord
    End If
    sSQL = "SELECT DoctorsID, AppointDate, AppointTime"
    sSQL = sSQL & " FROM qrySubformAppoints"
    sSQL = sSQL & " WHERE DoctorsID= " & Me.ID & _
                            " AND AppointDate=#" & Me.txtAppointDate & "#"
    Set oRS = CurrentDb.OpenRecordset(sSQL)
    
    dDuration = TimeValue("00:30")
    dLowerbreak = Break - TimeValue("00:25") 'Break is a field
    dUpperBreak = Break + TimeValue("00:25")
    
    If oRS.RecordCount = 0 Then
        Do
            If i <= dLowerbreak Or i >= dUpperBreak Then
                CboTime.AddItem i
            End If
            i = i + dDuration
        Loop Until i >= txtEnd
    Else
        Do
            If i <= dLowerbreak Or i >= dUpperBreak Then
                dLowerPrecision = i - TimeValue("00:00:05")
                dUpperPrecision = i + TimeValue("00:00:05")
                oRS.FindFirst "[AppointTime] Between #" & dLowerPrecision & "# And #" & dUpperPrecision & "#"
                If oRS.NoMatch Then CboTime.AddItem i
            End If
            i = i + dDuration
        Loop Until i >= txtEnd
    End If
    oRS.Close
End Sub

Private Sub cboTime_AfterUpdate()
    SubForm.SetFocus
    DoCmd.GoToControl "AppointTime"
    DoCmd.GoToRecord , , acNewRec
    SubForm.Form.Controls("AppointTime") = Me.CboTime
    SubForm.Form.Controls("AppointDate") = Me.txtAppointDate
    SubForm.Form.Controls("cboClient").SetFocus
    SubForm.Form.Controls("cboClient").Dropdown
End Sub

Private Sub txtAppointDate_BeforeUpdate(Cancel As Integer)
    If CDate(txtAppointDate) <= Date Then
        MsgBox "No more new appointments on this date"
        Cancel = True
    End If
End Sub

Richard Rost              
2 years ago
Your screen shot doesn't show which line is causing the error. That's kind of important.
Kevin Robertson           
2 years ago
What is the actual name of your Subform?
Recommended: Option Explicit
Richard Rost              
2 years ago
Definite good catch, Kevin. Without Option Explicit you could be missing all kinds of errors.
Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago
Hi Richard , Kevin

I add all the SS hope fully the SS it will be more help full

Thanks
Kevin Robertson           
2 years ago
Do you have a field called ID on the Form?
It may be mis-spelled or may be called something else.
Kevin Robertson           
2 years ago
If you remove the Me. does it work?

Bang! v Dot.
Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago
Hi Kevin

I uploaded both of them with SS right now
Kevin Robertson           
2 years ago
The field on the Form is DoctorsID
Change Me.ID to DoctorsID (you don't need the Me.)
Rami Kanawati OP     
2 years ago

Rami Kanawati OP     
2 years ago
Hi Kevin

I changed Me.ID to DoctorsID but i got other errors i upload SS for this compile errors
Richard Rost              
2 years ago
Rami, the error message that is popping up is telling you what the problem is. You have a variable that's not defined. If it's not a field on your form (which it isn't, otherwise you wouldn't get that message) then you have to Dim that as a variable. Based on the classes you've taken, I suggest that you're biting off more than you can chew right now. I would STRONGLY recommend watching my Access Developer 1 class at a minimum before continuing to work on your code. You're getting simple error messages that you don't know how to fix because you haven't had the training. That's a "VB 101" error.
Kevin Yip       
2 years ago
Hi Rami, regarding your original goal, you may want to use a date and time picker instead of date buttons to set the date and time on your appointment form.  You probably wouldn't want to click +1h eleven times and +1m thirty times to set 11:30am.  So picking the date and time from a picker would be a lot more efficient.  Search this site for "date time picker" for Richard's videos on the topic, which is a pretty advanced topic as well.  Regarding your earlier comment about "a simple requirement that shouldn't need high-level skills."  Unfortunately, everything in Access is high-level skills, since this is not exactly algebra and trigonometry.  Even the "beginner" courses are not easy; they are merely a starting point.
Richard Rost              
2 years ago
Well said, Kevin. I've also got this if you want something a little more Plug n Play: Access Date Time Picker

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Date Buttons.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 10/15/2024 1:11:28 PM. PLT: 3s