473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

pop up calenar not working in subform

I've got a form that has been quite happily useing a pop up calendar to
enter dates. However I've had to amend the world and add the form as a
subform. To my frustration, the pop up calendar now does not work on the
subform. Each time I click on the field, instead of allowing the date to
pop into the field, I just get an error message asking me if I really want
to close the calendar pup up.

Suggestions ??

Stinky Pete
Nov 13 '05 #1
3 2066
On Fri, 10 Jun 2005 14:59:53 +1000, "Stinky Pete"
<st*************@hotmail.com> wrote:
I've got a form that has been quite happily useing a pop up calendar to
enter dates. However I've had to amend the world and add the form as a
subform. To my frustration, the pop up calendar now does not work on the
subform. Each time I click on the field, instead of allowing the date to
pop into the field, I just get an error message asking me if I really want
to close the calendar pup up.

Suggestions ??

Stinky Pete


Without looking at the code, it's really hard to say, but you may have one of
the many implementations of a calendar form that's written to try to look back
into the form it's called from. If so, that's a nasty, circular dependency
that should be removed, but without seeing exactly what you have, we can't
give you any concrete advice.
Nov 13 '05 #2
Fair point ;-)

The code that is working on the form to pup up the calendar is ...

Private Sub Date_Complete_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
DoCmd.OpenForm "frmCalendar"
With Forms!frmCalendar
.txtFormName.Value = Me.Name
.txtControlName.Value = Me.ActiveControl.Name
If IsDate(Me.ActiveControl.Value) Then
.ocxCalendar.Value = Me.ActiveControl.Value
Else
.ocxCalendar.Value = Date
End If
End With
End Sub

and the code for the acutal calendar (which is a form) is ...

Private Sub cmdOK_Click()
On Error GoTo cmdOK_Click_err
Forms(Me.txtFormName.Value).Controls(Me.txtControl Name.Value).Value = _
Me.ocxCalendar.Value
cmdOK_Click_exit:
DoCmd.Close acForm, Me.Name
Exit Sub
cmdOK_Click_err:
Select Case Err.Number
Case 2450
MsgBox "You closed the form. Why?!?", vbCritical, "Error!"
Case Else
MsgBox "Well, that wasn't very bright!", vbCritical, "Error!"
End Select
Resume cmdOK_Click_exit
End Sub

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:v6********************************@4ax.com...
On Fri, 10 Jun 2005 14:59:53 +1000, "Stinky Pete"
<st*************@hotmail.com> wrote:
I've got a form that has been quite happily useing a pop up calendar to
enter dates. However I've had to amend the world and add the form as a
subform. To my frustration, the pop up calendar now does not work on the
subform. Each time I click on the field, instead of allowing the date to
pop into the field, I just get an error message asking me if I really want
to close the calendar pup up.

Suggestions ??

Stinky Pete


Without looking at the code, it's really hard to say, but you may have one
of
the many implementations of a calendar form that's written to try to look
back
into the form it's called from. If so, that's a nasty, circular
dependency
that should be removed, but without seeing exactly what you have, we can't
give you any concrete advice.

Nov 13 '05 #3
As I suspected, this is one of those calendar designs that's pathologically
coupled to its caller. The code assumes it will write a value back to a
control on the caller's form using Forms(<formname>.Controls(<controlname>).
It would be far better if the calendar had no idea the nature of thing the
selected date is being written back to, and the caller doesn't need to know
how the calendar is implemented. The call would then look something like
this...

Private Sub Date_Complete_MouseDown(...
CalendarInput Me!Date_Complete
End Sub

Without knowing what the code on the calendar form itself looks like, I can't
tell you all of what the CalendarInput function would look like, and what the
code on the calendar form would look like, but part of it would probably look
something like this...

Public Sub CalendarInput(ByRef DateValue As Variant)
Const cstrFormName = "frmCalendar"

DoCmd.OpenForm FormName:=cstrFormName, _
WindowMode:=acDialog, _
OpenArgs:=DateValue

Dim frmCalendar As Access.Form
On Error Resume Next
Set frmCalendar = Forms(cstrFormName)
On Error Goto 0: Err.Clear

If frmCalendar Is Nothing Then Exit Sub

Dim varDateSelected As Variant
varDateSelected = frmCalendar!ocxCalendar.Value

Set frmCalendar = Nothing
DoCmd.Close acForm, cstrFormName

If IsObject(DateValue) then
'Write the selected value back to the default value property of
'the DateValue object passed.

Dim objDateValue As Object
Set objDateValue = DateValue

objDateValue = varDateSelected

Else
'Just return the value by reference to the variable supplied for
'DateValue.
DateValue = varDateSelected
End If

End Sub

Because we open the calendar form with acDialog, our code waits until the
calendar form is closed or hidden before it can continue. On the calendar
form, the code says Me.Visible = False after the user is done selecting a
value, so the calling code continues, but the form remains open for reading
the result. If the user cancels the selection, the form simply does
DoCmd.Close acForm, Me.Name to close itself, and the calling code knows that a
closed calendar form means there's no value to get.

On Fri, 10 Jun 2005 15:46:45 +1000, "Stinky Pete" <ca************@hotmail.com>
wrote:
Fair point ;-)

The code that is working on the form to pup up the calendar is ...

Private Sub Date_Complete_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
DoCmd.OpenForm "frmCalendar"
With Forms!frmCalendar
.txtFormName.Value = Me.Name
.txtControlName.Value = Me.ActiveControl.Name
If IsDate(Me.ActiveControl.Value) Then
.ocxCalendar.Value = Me.ActiveControl.Value
Else
.ocxCalendar.Value = Date
End If
End With
End Sub

and the code for the acutal calendar (which is a form) is ...

Private Sub cmdOK_Click()
On Error GoTo cmdOK_Click_err
Forms(Me.txtFormName.Value).Controls(Me.txtControl Name.Value).Value = _
Me.ocxCalendar.Value
cmdOK_Click_exit:
DoCmd.Close acForm, Me.Name
Exit Sub
cmdOK_Click_err:
Select Case Err.Number
Case 2450
MsgBox "You closed the form. Why?!?", vbCritical, "Error!"
Case Else
MsgBox "Well, that wasn't very bright!", vbCritical, "Error!"
End Select
Resume cmdOK_Click_exit
End Sub

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:v6********************************@4ax.com.. .
On Fri, 10 Jun 2005 14:59:53 +1000, "Stinky Pete"
<st*************@hotmail.com> wrote:
I've got a form that has been quite happily useing a pop up calendar to
enter dates. However I've had to amend the world and add the form as a
subform. To my frustration, the pop up calendar now does not work on the
subform. Each time I click on the field, instead of allowing the date to
pop into the field, I just get an error message asking me if I really want
to close the calendar pup up.

Suggestions ??

Stinky Pete


Without looking at the code, it's really hard to say, but you may have one
of
the many implementations of a calendar form that's written to try to look
back
into the form it's called from. If so, that's a nasty, circular
dependency
that should be removed, but without seeing exactly what you have, we can't
give you any concrete advice.


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Scott | last post by:
In my database, I have a form with a subform. I had everything working correctly - the correct records would display on the subform for each record on the form. I could edit, add, and delete on the...
5
by: Bill Stock | last post by:
I'm inherited a database that has a few issues. One of the less severe issues, but the one the users bitch about is the speed across the LAN. So I thought that I could unbind the NUMEROUS subforms...
6
by: tlyczko | last post by:
I have a BeforeUpdate where I need to ensure that no matter what, the first four fields on the form (one text box, 3 combo box lists) have data entered in them before the user closes the form or...
8
by: Robert | last post by:
I have a form (Worksheet) that works fine by itself. I have now created a seperate form (MainForm) that has a command button in the header and an unbound subform (FormFrame) in the Detail section....
3
by: wvhines | last post by:
Hello: I am an ambitious novice...I have a main form "frmGeneralContracting" that has a subform on it called "frmsubDeliverables" and I am trying to restrict editing if the current user's login...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
14
by: David Grist | last post by:
Hello, Any help would be appreciated!!! I need to sum AMOUNTTEND on a receipts subform that meet a certain criteria. It has to be something like. =sum() where ="tour installment"
14
kcdoell
by: kcdoell | last post by:
Hello: I have a form (Default view =single form) with a subform (Default view =continuous forms) embedded into it. In the form I have three controls that display the Division, Working Region &...
4
by: mgstlucia | last post by:
I have a Form (frmsOrders) with a subform (frmOrdersDetails Subform). I am trying to automatically fill in the Item Description, Unit and Price when choosing the SKU# from a combobox. I have this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.