allen browne calendar problem

C

Chris

Hi,

I'm using Allen Browne's calendar on my form to enter the date of the
salesrep's visit and the duedate of the action to be done.
This works fine the first time, but when I click the 'add new record'-button
on my form, I get the message 'the property or method is not supported by
this object' when I click on the OK button on the calendar form to confirm
the chosen date.

Any suggestions how to solve this problem?

Thanks,
Chris
 
C

Chris

Additional info:

this problem occurs with access 2007. In access 2003 everything works fine.

Chris
 
J

Jeanette Cunningham

Hi Chris,
I have used Allen Browne's calendar in A2007, so I can confirm that it isn't
a problem with the calendar.
Would you explain how your 'add new record' button is related to the OK
button on the calendar form so we can better understand the problem you
have.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

Chris

Hi Jeanette,

the sales rep's info form is a continuous form. It has several text fields
on it, including the 'datum contact' field. Next to this field is a button
to open the pop-up calendar. After chosing the date and clicking the OK
button on the calendar form, the datum contact field is filled with the
chosen date on the calendar form.
In the form header is another button to add a new record.
This is the code:
Private Sub btnAddNew_Click()
On Error GoTo Err_btnAddNew_Click
datum_contact.SetFocus
DoCmd.GoToRecord , , acNewRec

Exit_btnAddNew_Click:
Exit Sub

Err_btnAddNew_Click:
MsgBox Err.Description
Resume Exit_btnAddNew_Click
End Sub

My cursor jumps nicely to the datum contact field, when I click the open
calendar form button, the form opens. But when I want to confirm my chosen
date by clicking the OK button on the calendar form I get the error message.

I hope all this makes sense and helps you find a solution.

Kind regards,
Chris
 
J

Jeanette Cunningham

Hi Chris,
my first thought is to explicitly save the chosen date before adding a new
record.
Also temporarily move the setFocus line to after going to the new record.
Try something like this-->

Private Sub btnAddNew_Click()
On Error GoTo Err_btnAddNew_Click
If Me.Dirty Then
Me.Dirty = False
End If

DoCmd.GoToRecord , , acNewRec
Me.datum_contact.SetFocus

Exit_btnAddNew_Click:
Exit Sub

Err_btnAddNew_Click:
MsgBox Err.Description
Resume Exit_btnAddNew_Click
End Sub



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

Chris

Hi Jeanette,
tried it but no success.

Chris

Jeanette Cunningham said:
Hi Chris,
my first thought is to explicitly save the chosen date before adding a new
record.
Also temporarily move the setFocus line to after going to the new record.
Try something like this-->

Private Sub btnAddNew_Click()
On Error GoTo Err_btnAddNew_Click
If Me.Dirty Then
Me.Dirty = False
End If

DoCmd.GoToRecord , , acNewRec
Me.datum_contact.SetFocus

Exit_btnAddNew_Click:
Exit Sub

Err_btnAddNew_Click:
MsgBox Err.Description
Resume Exit_btnAddNew_Click
End Sub



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
J

Jeanette Cunningham

There could be some other code on the form that is interferring with the
calendar.
Temporarily comment out all code on the form and then just uncomment the
lines needed to go to a new record and use the calendar.
See if this approach helps you discover the problem.

Another possibility is some start of corruption on your form.
To test this, I create a very basic new form from scratch. Put only the bare
minimum of controls on the form - such as the primary key, the date
field/control, the add new button and the calendar button - test and see
what happens.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

Chris

Hi Jeanette,

there was some other code on the form. After removing that, the problem was
solved.
This brings up another question though.
The code I removed was to carry over data from the previous record to the
new record:
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim strMsg As String
Call CarryOver(Me, strMsg, "verslag_contact", "actie_todo",
"actie_duedate", "datum uitvoering")
If strMsg <> vbNullString Then
MsgBox strMsg, vbInformation
End If
End Sub
How do I get this to work in A2007?

Chris
 
J

Jeanette Cunningham

A2007 is a little more fussy or more strict than A2003 with some code.
It is a long time since I have used carry over code, I forget what problems
may eventuate.
A couple of things to try-->
1. Try moving the carry over code to a different event, for example the
current or load events.

2. Experiment with removing any date field/controls from the carry over
routine.

3. I am not familiar with the CarryOver routine- maybe there is a way to
tweak the code in it.

4. Find a different way to setup the default values for those field/controls
instead of using the CarryOver code.

Hope something from the above helps.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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