Results 1 to 3 of 3
  1. #1
    seashton is offline Novice
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    NC (USA)
    Posts
    3

    Need some help revising some code...

    I am not very good at revising code and need suggestions how to get some code to do the things I want. Below I have code that gets the appointments for the active date BUT I also need to get those appointments by ApptLocation field as well as the ApptDate from tblAppointments. Can some make some suggestions?

    strSQL = "SELECT tblAppointments.*, tblHour.HourID " & _


    "FROM tblAppointments INNER JOIN tblHour " & _
    "ON tblAppointments.ApptStartTime = tblHour.Hours " & _
    "WHERE tblAppointments.ApptDate = #" & dtePubMyDate & "# " & _
    "ORDER BY ApptStartTime;"

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    since

    strSQL = "SELECT tblAppointments.*, tblHour.HourID " & _
    "FROM tblAppointments INNER JOIN tblHour " & _
    "ON tblAppointments.ApptStartTime = tblHour.Hours " & _
    "WHERE tblAppointments.ApptDate = #" & dtePubMyDate & "# " & _
    "ORDER BY ApptStartTime;"


    is to get appointment on that date, so dtePubMyDate looks like a textbox in the form. if you want to get appointment by location, assume there is a control apptLocation in the form, then the code will be:

    strSQL = "SELECT tblAppointments.*, tblHour.HourID " & _
    "FROM tblAppointments INNER JOIN tblHour " & _
    "ON tblAppointments.ApptStartTime = tblHour.Hours " & _
    "WHERE tblAppointments.Apptlocation = '" & apptlocation & "' ORDER BY ApptStartTime;"


    if you want to get appointment by both date and location:

    strSQL = "SELECT tblAppointments.*, tblHour.HourID " & _
    "FROM tblAppointments INNER JOIN tblHour " & _
    "ON tblAppointments.ApptStartTime = tblHour.Hours " & _
    "WHERE tblAppointments.ApptDate = #" & dtePubMyDate & "# and tblAppointments.Apptlocation = '" & apptlocation & "' ORDER BY ApptStartTime;"

  3. #3
    seashton is offline Novice
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    NC (USA)
    Posts
    3

    Need some help revising some code...

    Thanks, your suggestion has worked but I do not think I have my logic is quite right for this form. The ApptLocation control is a combo box based on tblAppointments records and it needs to reflect the records associated with the date shown in Date textbox on the form and this is not working.

    I do not think the ApptLocation control is the way to do this. I would like to have this form open so the ApptLocation control populates based on the date shown in the date textbox or do I need to to make the ApptLocation a textbox also and have code populate it the same way the Date textbox does. Below is how the Date textbox is updated on form.

    'Update the active date in the form header
    Me.lblDate.Caption = Format(dtePubMyDate, "Long Date")

    There also could be many ApptLocation records for each date, is there a way to place controls on form to pick a diiferent ApptLocation like I have the ability to pick different dates with the Date textbox on the form (see attached sceenshot of form for reference)
    [IMG]file:///C:/Users/seashton/AppData/Local/Temp/moz-screenshot-4.png[/IMG][IMG]file:///C:/Users/seashton/AppData/Local/Temp/moz-screenshot-5.png[/IMG]

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  2. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  3. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  4. Help with VBA Code
    By access.newby in forum Forms
    Replies: 1
    Last Post: 11-15-2009, 05:43 AM
  5. Need help with code
    By hoenheim in forum Programming
    Replies: 9
    Last Post: 09-11-2008, 04:19 PM

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