Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / February 2008

Tip: Looking for answers? Try searching our database.

Behaviour depends on the placement of DoCmd Close, acform...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SlowArrow - 31 Jan 2008 12:12 GMT
Dear Form Gurus,

I've made a popup, modal dialog form in MS Access 2003 holding just an
MSCAL.OCX type Calendar control. I'm calling it from the MouseDown events of
some comboboxes of a non-modal sizable form. In the caller event I open the
form with the DoCmd.Open as a dialog form, and pass the value of the actual
date of the combobox together with the actual mouse position to the
Calendar-form. Clicking a date of the calendar control I dont close its form,
however i hide it, and I get back the selected date by the code in the caller
event. Then I close the Calendar-form.
However, this does not work correctly, if i use 2 comboboxes, the openarg
contains nothing. If i place do closing just before the opening of the
Calendar-form, then it works well. I would appreciate, if you explain this?

All the related code is below.

Thanks, ahead:-)

SlowArrow

The caller form's codes:

Private Sub START_DATE_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
   SetDate Me.START_DATE, X
End Sub

Private Sub END_DATE_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
   SetDate Me.END_DATE, X
End Sub

Private Sub SetDate(ByRef cmbDate As ComboBox, X As Single)
   Dim ResultFlag As Integer, hTitle As Integer, myDate As Date, strArgs As
String
   hTitle = GetSystemMetrics(SM_CYSIZE)               ' height of a button
in a window caption or title bar
   If X > cmbDate.Width - 15 * 20 Then
       If cmbDate.ListCount > 0 Then cmbDate.RemoveItem 0
       cmbDate.AddItem cmbDate.Value
       SendKeys "^{UP}{ESCAPE}"
   Else
       myDate = cmbDate.Value
       strArgs = cmbDate.Text & "|" & CStr(Me.WindowTop + cmbDate.Top +
cmbDate.Height + hTitle * 20) & _
                                "|" & CStr(Me.WindowLeft + cmbDate.Left +
cmbDate.Width - Form_Calendar.Width) & "|" & cmbDate.Name
'        Debug.Print "Form_Call: """ & strArgs & """ - " & CStr(ixCount)
'        On Error Resume Next
       DoCmd.Close acForm, CalendarDialog
       DoCmd.OpenForm CalendarDialog, , , , , acDialog, strArgs
       ResultFlag = Forms(CalendarDialog).Form.Tag
       If ResultFlag = vbOK Then myDate =
Forms(CalendarDialog)!ocxCalendar.Value
'        DoCmd.Close acForm, CalendarDialog
       cmbDate.Value = myDate
   End If
   cmbDate.SetFocus
End Sub

The Calendar-form's codes:

Private Sub Form_Load()
   If Not IsNull(Me.OpenArgs) Then
       Dim MyArray() As String
       MyArray = Split(Me.OpenArgs, "|")
       Me.ocxCalendar.Value = CDate(MyArray(0))
       Me.Move Left:=Int(MyArray(2)), Top:=Int(MyArray(1))
'        Debug.Print "Form_Load: """ & Me.OpenArgs & """ - " & CStr(ixCount)
'        ixCount = ixCount + 1
   End If
End Sub

Public Sub ocxCalendar_Click()
   Me.Visible = False
   Me.Tag = vbOK
End Sub
SlowArrow - 31 Jan 2008 15:25 GMT
I want to explain a bit better the situation in the wrong case (when I put do
DoCmd.Close ... statement for the CalendarDialog _following_ the line serving
for obtaining the selected date):

Immediately after opening the caller window I clicked on one of the Combo
boxes. The CalendarDialog form appears, as we expect it, and it is possible
to select a date by its MSCAL.OCX calendar control, by clicking a date. Then
this form disappears from the screen (because of setting the Visible property
to False in the control's click event). Then I clicked on the other combobox.
The calendar form appeared, _but in its previous place_, meaning that the
OpenArgs was null in the Form_Load event. The contents of the OpenArgs seems
to be correct at the time of the call. I've realised, that the Form_Load is
activated twice: at first with empty OpenArgs, and sometimes with its correct
value. I'm a bit confused about these. I would like to ask some expalnation
for this.
SlowArrow - 01 Feb 2008 11:30 GMT
I'm not impatient, just like to know, wether this is the correct forum for my
question, or should i post it under the Access.formscoding... besides the
answer for my original question:)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.