Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box & Calendar Problem 1

Status
Not open for further replies.

Kirzman

Vendor
Jul 30, 2008
7
GB
Ok I have a relatively simple problem I think!

I am using the Calendar feature in Ms Access and a combo box to input dates into my form (The form is called Main)

I have got it all working so when I select a date from the calendar it updates the combo box. But I simply wish to save the date so when I close the database down it's still there the next time.

My combobox is called cboDate. I figured the easiest way to save the date is to put the following code into my master query

[Forms]![Main]![cboDate]

I then run a make table query and all my reports are driven off this master table. With a now static date column.

Problem : When I try and link to the combo in a query it just brings back blank.

If I however go into the combobox and type the date in rather than pick it from the calendar it works. So something is not quite right between the calendar and the combo box. I think it's something to do with the format of the combo box.

At the minute my work around is just to type the date into the combo box but I'd prefer to get the calendar bit working.

Be grateful for any help. Please forgive me if I've not provided enough detail etc as I'm quite new to all of this!

Kind Regards
Kieran
 
Why are you using a combo box at all?

Have you tried changing your combo box to a text box?

If you're simply using it as a date picker, you should just be referring to the calendar object, or if you want to use a textbox or combo box or whatever, you should use the AfterUpdate event of the calendar or possibly OnChange event to set the value of the combo box or text box to equal the value of the calendar control.

Another problem could be in the way your form is connected to your table recordsource. Is the combo box's control source an actual field in your table? If not, then try setting that correctly, and it alone could fix the issue - assuming you are assigning the value from the calendar control to the combo box.

--

"If to err is human, then I must be some kind of human!" -Me
 
Hi Kjv thanks for your reply

I've not considered a text box but could give it a go.

On Mouse down I have set the value of the combo box to equal the value of the calendar control. As I say the date appears to update properly as puts a revised date in the combo box

The problem could be record source. The combo box is currently unbounded. It's picking the dates from the calendar? Do I need to set it to some blank fields in my table for it to update?

If I try and set the control source to a field in a table I get a debug error at [Calendar.Value = cboDate.Value]

I've attached my code.

Code:
Private Sub cboDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Calendar.Visible = True
Calendar.SetFocus
If Not IsNull(cboDate) Then
   Calendar.Value = cboDate.Value
Else
   Calendar.Value = Date
cboDate.SetFocus

End If

End Sub

Code:
Private Sub Calendar_Click()

cboDate.Value = Calendar.Value
cboDate.SetFocus
Calendar.Visible = False

End Sub
 
If I try and set the control source to a field in a table I get a debug error at [Calendar.Value = cboDate.Value]
Is the Calendar control's control source pointing to the same location as the combo box?

--

"If to err is human, then I must be some kind of human!" -Me
 
The calendar control's source is blank. I'm not sure I know how to change that!

It's so frustrating. I change the combo box to a text box and it again seems to work fine and brings the date through properly but when I try to bring it through in the query I get nothing

As soon as I overtype the date manually it brings it through in the query!
 
Arr I got it now. I wasn't binding the combo box properly. Once I'd set the record source correctly it's updating into the table properly and saving how I want it too

Thanks for your help kjv
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top