Page 3 of 3 FirstFirst 123
Results 31 to 35 of 35
  1. #31
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862


    Quote Originally Posted by AccessHelp12 View Post
    subform.SetFocus


    the subform.setfocus gets highlighted in yellow
    subform.SetFocus

    This code is trying to setfocus on the subform container so the Docmd will function properly. You need to replace "subform" with the name of your subform container. On your main form select your subform container and look at the properties sheet. On the other tab the name of your subform container will be displayed.

  2. #32
    Join Date
    Jan 2014
    Posts
    28
    Thanks ItsMe but i already got told that this was the problem.
    the problem i am seeking help in now is writing code so that the combobox works in a way that if the time slot has been selected it is no longer shown in the combo box for that day .
    Eg/; 2/2/2014 10:00AM is already booked with a client
    the combo box should no longer display the 10:00 AM timeslot but can be shown on other days
    This is to prevent error of double bookings in case the user does not realise their is an appointment booked for that time slot on that day
    Do You know how i would need to write this in VBA code
    Please help as soon as you can because this project is due in very soon
    thanks

  3. #33
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would suggest copying the code from the video and double checking the names of your controls and forms. It is more difficult for others to interpret a tutorial and then convey how to do it than for you to follow the tutorial and ask specific questions. Simply stating, I need to update such and such is not enough. Keep going over the code until it is obvious where the issues are.

  4. #34
    Join Date
    Jan 2014
    Posts
    28
    Hey Guys
    I managed to download the database the user used within the video.
    Below is the code he used to design the form
    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


    I found out that the combo box does not work like it does in the video i.e the option does not dissaspear even though their has been a booking with that time slot with another client.
    Can anyone help me figure out the coding that is required to make the combo box work like that or is their an error within the code that is preventing the combo box to work in such manner

    Thank You

  5. #35
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    One thread on an issue is enough. I am locking this one. I don't want to merge because this one is so long and don't want to delete. Continue discussion in the other thread.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  2. Compile Error: Syntax Error in DoCmd.RunSQL Statement
    By Evilferret in forum Programming
    Replies: 1
    Last Post: 08-27-2012, 12:32 PM
  3. Replies: 2
    Last Post: 06-23-2012, 11:59 PM
  4. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  5. Replies: 6
    Last Post: 09-28-2011, 09:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums