Individual values in combo box

D

davethewelder

Hi, I have a form in datasheet view and I have added a unlinked combo box
with a time to book e.g 09:15, 09:30 etc. When I select 09:15 it populates
all records in the form.
Is it possible to restrict this to one values per record?

All help appreciated.

Davie
 
B

bcap

If the combo box is unbound then the value you choose for it is not part of
the record, so no, it is not possible to choose a different value for each
record in an unbound combo box.

If you could explain a bit more about why you want to do this then I'm sure
suggestions would be forthcoming.
 
D

davethewelder

bcap, thanks for the response.
What I am tryiing to do is allow users to click on the drop down and select
a date for booking appointments.
I have created a form with a combo box formatted to date and have tried to
use the code and instructions from an article posted on
http://www.fontstuff.com/access/acctut09pfv.htm which gives you a pop up
calendar, which would be ideal.

I have followed the instruction, code below, but get the error message
"Microsoft cannot move the focus to the control Calendar3" and debugs to the
line Calendar3.SetFocus line.

Private Sub Combo21_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Calendar3.Visible = True
Calendar3.SetFocus

If Not IsNull(Combo21) Then
Calendar3.Value = Combo21.Value
Else
Calendar3.Value = Date
End If


End Sub

Any ideas?

Davie
 
B

bcap

Perhaps if we could solve one problem at a time. The use of a calendar
control is not related to your original question.

So, why is this control not bound? Surely if an appointment date is entered
(by whatever means) then you want to save it on the record, so surely the
control should be bound to a field? If so, then your original problem goes
away. If the appointment date is not bound, then what's the point in
entering it? It would simply be lost when the form was closed.

As for why the code doesn't work, you said that the form is in datasheet
view. An ActiveX control such as the calendar doesn't have a prayer of
working in datasheet view, because there is no way of displaying it. It
might work in continuous forms view.

Personally I never use ActiveX controls because of the "dll hell" problems
that can occur when deploying and supporting applications which use them.
This is a good alternative:

http://www.lebans.com/monthcalendar.htm

What's more, since this calendar pops up rather than being a control on the
form, it *might* work in datasheet view (although I've never tried it).

Why are you using a combo box when you want to provide a date picker? I'd
have thought that a text box would be perfectly adequate since you are
providing an alternative method of choosing a date (i.e. a calendar).
 
D

davethewelder

bcap, you are correct that I am posting tow different problems. I don't have
much experience with forms. Your advice made the link and I have now managed
to make the combo box populate the field I added into the table, (after
reading your reply).

I was thinking to far ahead of myself.

Thanks for the advice.

I will look at calendars url you supplied for another form and see if I can
work it out.

Thanks again,

Davie
 
B

bcap

If you want to use the Lebans calendar, there are some detailed instructions
there about how to use it, which have been kindly provided by another party.
However, I have a *much* simpler method for using it, please post back if
you plan to go ahead.
 
D

davethewelder

bcap, I would still like to use the calendar option on my forms. I would
appreciate if you could let me know your method.

cheers,

Davie
 
B

bcap

OK, download the files from the Lebans website and import into your database
as instructed.

Create the following procedure in standard module:

Sub Calendar()

Dim mc As clsMonthCal
Dim blRet As Boolean
Dim dtStart As Date, dtEnd As Date

Set mc = New clsMonthCal
mc.hWndForm = Screen.ActiveForm.hWnd

dtStart = Nz(Screen.ActiveControl, 0)
dtEnd = 0

blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
If blRet = True Then
Screen.ActiveControl = dtStart
Else
' Add any message here if you want to
' inform the user that no date was selected
End If

Set mc = Nothing

End Sub

Then, in the Click event of your text box or combo box, the only code
statement you need is simply this:

Calendar
 
F

Faye

what if you really don't want to save the choice they make in the combo box,
but still want to have the ability for the user to choose a different value
for each record on the form? Is that possible?
 
J

John W. Vinson

what if you really don't want to save the choice they make in the combo box,
but still want to have the ability for the user to choose a different value
for each record on the form? Is that possible?

So you want to
a) Not save the choice they make in any record and
b) Do save the choice they make in every record?

You've got to save the information SOMEWHERE if you want the user to make a
selection and have it stick.

One possible source of confusion: on a continuous form it LOOKS LIKE there are
as many combo boxes (unbound combo boxes!) as rows. There aren't. There is
only ONE combo box displayed many times. If you change its properties or
content, that's what you'll see on every record.
 
F

Faye

Thanks for taking the time to answer my question, John. Even though it
wasn't the answer I wanted. :)

Faye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top