Duane,
I did as you said but I think I may have done it incorrectly. I created a
module for the form. I placed your code in it with my data fields.
Then, I placed the code in a private sub form for the got focus event on
Atime. This didn't work so I thought I needed to call the module function.
However, I must be doing that incorrectly as well. How does one call a
function in VB for the private sub?
Would it be:
UpdateRowSourceProp
or is it much more complicated than this?
I really do appreciate the time you've spent walking me through this
process.
Duane Hookom said:
Since I was not sure what your list box of times was named, I provided
one
for you of "lboSelectTime". Substitute your actual list box name or
change
your name to match the code.
--
Duane Hookom
MS Access MVP
Vella said:
Duane,
I must be very simple. I thought I had put everything in the
appropriate
place(s).
Yet, I get an error code of : can not find object and the lboSelectTime
is
highlighted. Or when I make adjustments, it just doesn't work.
I know this is entirely due to the fact that I am not putting things
where
they belong.
I'm sure this is frustrating to you but if you could see your way clear
to
walking me through this process, I would appreciate that very much.
:
I would write a function in the form's module
Public Function UpdateRowSourceProp()
Dim strSQL as String
strSQL = "SELECT ApptTime from AppointmentTimes " & _
"WHERE ApptTime not in (Select " & _
"Appointment_Time from Table1 where " & _
"[Date] = #" & Me!Date & "#);"
Me.lboSelectTime.RowSource = strSQL
End Function
You can place this function in the Form On Current and Me.Date After
Update
event properties.
--
Duane Hookom
MS Access MVP
Duane,
Yes, I am using a sql query as the row source. I understand that
the
code
you wrote is VB but I am unsure of how to place it in order for it
to
be
used
as a row source. Would that be an Onclick event...? totally lost.
Newbies can be such a trial! I appologize.
:
Can we assume the sql you provided is the Row Source property of
the
combo
box? If so, try use code to change the row source to:
strSQL = "SELECT ApptTime from AppointmentTimes " & _
"WHERE ApptTime not in (Select " & _
"Table1.Appointment_Time from Table1 where " & _
"Table1.Date = #" & Me!Date & "#);"