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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cal + other 1

Status
Not open for further replies.

dan9991

Programmer
Feb 25, 2003
27
GB
I have imported an active x control known as calender 9.0 control. However i have tried using simple code to link up with a table on the form but can't get it working. I also have a combo box on the form. There is a specific field called return_date. I want to be able to use my combo box to display a record then the return date is shown on the calender. I also want to be able to click on a date and it will show the record for that date. Could someone help please.

My other question is that in Msaccess 2000 and windows Xp you can run applications, which usually work. On xp i was given a basic narater. However i can't seem to get it to work on reading out the forms main menu. Please let me know. Stars will be going out.
 
To answer the first question, I would suggest ensuring that you have properly wired-up the datasource to the control. In my example I have a calendar control named myCalendar. I want to sync it with a textbox on my form named txtOrderDate. so I write the one line of code to do this.

Private Sub Form_Current()

myCalendar.Value = txtOrderDate.Value

End Sub

Now every time you move from one record to the next (or refresh the record) it will reSync. The next part of this is to use the calendar to modify the Textbox (as well as anyother control on the form). This is simply a matter of locating the event you care about and placing code within it to react when that event fires.

Private Sub myCalendar_AfterUpdate()

'Test to see if they want to change?
If vbYes = MsgBox("Are you sure you " & _
"want to chnage the date?", vbQuestion + _
vbYesNo, "Change Date?") Then
txtOrderDate.Value = myCalendar.Value
End If

End Sub

As for the 2nd question - not sure what your asking.

Hope this helps!

Jim
 
I managed to get the calender to display a message box saying there is no record all on the one record which is great however it does not search for all the records. I would like the calander to be like a combo box where dates can be clicked on and either a blank record is shown or the date with the record. Thanks very much for last reply will be rewarding stars
 
Here is one possible solution, I hope your ready for this one:

I created 2 Forms. First Form is an Auto Form of Orders w/ Details form from Northwind. Next I added 3 buttons each with a Find Icon placed next to the 3 Date fields that were generated. The example I am presenting targets only the OrderDate field, but has been built to handle any date field.

Here is the Click event for the Commandbutton:
Private Sub cmdFindOrderDate_Click()

'Openargs contains the Forms Name Property and
'is concatenated w/ the pipe character and
'Field name to be searched.
DoCmd.OpenForm "frmDateFinder", acNormal, OpenArgs:=Me.Name & "|OrderDate"

End Sub

The second form is a Pop-up Dialog Form named frmDateFinder, with a single calendar control in it. The code is in two event procedures and two module scoped variables:

Private m_frmOriginal As Form
Private m_strFieldName As String

Private Sub Form_Open(Cancel As Integer)

Dim strOriginalForm As String
Dim arrOpenArgs() As String
'Verify that a Form.Name was passed in
'If not catch the null as an empty string
strOriginalForm = Nz(Me.OpenArgs, "")

'Test for null, if not Set private variable to original form
'and field to perform find on.
If strOriginalForm <> &quot;&quot; Then
'Split out the text into an array. Set the variables.
arrOpenArgs = Split(strOriginalForm, &quot;|&quot;)
Set m_frmOriginal = Forms(arrOpenArgs(0))
m_strFieldName = arrOpenArgs(1)
End If

End Sub

Private Sub myCalendar_AfterUpdate()

Dim rst As Object
Set rst = m_frmOriginal.Recordset.Clone

rst.FindFirst m_strFieldName & &quot; = #&quot; & myCalendar.Value & &quot;#&quot;
If Not rst.EOF Then m_frmOriginal.Bookmark = rst.Bookmark

End Sub

As you can see when the form is open, it parses the Form Name and Field Name into array then to set a reference to the form and second to set the field that will be queried.

The AfterUpdate procedure is simply creating a clone on the recordset your looking at and performing a search on it. It then sets the bookmark property for the underlying recordset. This procedure can be modified to display a message that no record was found.

I hope this helps!

Jim Hope this helps!

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top