• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1105
  • Last Modified:

Microsoft, Access, 2003, active x controls in form: how to get their values into a field

Hello,

I'm using the LANDesk Date Control for a date field, but I don't know how to take the selected value and assign it to a given field.

Thanks!!!!
0
dustywork
Asked:
dustywork
  • 6
  • 4
1 Solution
 
Wayne Taylor (webtubbs)Commented:
Hi dustywork,

I'm not familiar with the LANDesk Date Control, but I assume it has a Control Source property? If so, set this to the required field.

Regards,

Wayne
0
 
GRayLCommented:
open the form in design view. Right-Click on the control, select Properties, Other tab, and record the name of the control.

In the OnClick event of a command button named cmdUpdate, insert this code:

Private Sub cmdUpdate_Click()
  Me.recordset.edit
  Me.recordset!fldName = Me!ctlName.Value
  Me.recordset.update
End Sub


replace fldName with actual field name and ctlName as you recorded above
0
 
GRayLCommented:
I am assuming your form is bound to the table in question?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dustyworkAuthor Commented:
Hi GRayL,

I tried your code, but the control only has the following events available:
OnUpdated
OnEnter
OnExit
On Got Focus
On Lost Focus

There is no Control Source property for this control.

I used your code with the OnExt event and received an error message:

Private Sub LDDate7_Exit(Cancel As Integer)
  Me.Recordset.Edit
  Me.Recordset!SurveyDate = Me!LDDate7.Value
  Me.Recordset.Update
End Sub

Error message:  This action was canceled by an associated object.
0
 
dustyworkAuthor Commented:
GRayL,

I wasn't clear in my last reponse that I would prefer the value to be recorded in the table as part of the normal user entry process (i.e. not as a separate button to click... not sure if that was what you were suggesting).

Yes, the form is bound to the table in which the Date field exists.
0
 
GRayLCommented:
I said OnClick of a command button not the ActiveXCtl.  You select a date in the date picker and then click the command button named cmdUpdate.  Does it help to set the control source of the control to the field SurveyDate.  I'm not familiar with that control and there may be another property you have to set to allow the control to update the field to which it is bound.  Give it a try and let us know what happens.
0
 
GRayLCommented:
I just did some test on my old Calendar control.  With the form bound to the table, set the control source of the calendar control to the field name SurveyDate.  I did not need any other code.   Then by scrolling through a recordset, a null date was indicated by no day of the month being highlighted in the calendar.  At any point I could select a month and a day, and it updated the field automatically.
0
 
dustyworkAuthor Commented:
GRayL,

Thanks for the responses.  The Active X control Calendar 5 does have a ControlSource property. So, that was easy.  I was hoping to use one of the sexier, drop-down calendar controls (specifically PjCalendar6).  unfortuantely, that control does not have a ControlSource property.

To be clear that I understand you, you are suggesting creating a command button that will take the value from the control and put it into a field via that code?  I was hoping for something more seamless, but I may not be fully understanding.
The control, PjCalendar6, is accessed via the Insert, ActiveXControls in the design view of Forms.  If you have a moment, I would love your insight as to how I may seek the final result I'm looking for.  Otherwise, I can use the bigger calendar control (no pretty, but functional).

Thanks again.  I do appreciate your time!
0
 
GRayLCommented:
Not knowing your form was bound to the table, ie. the calendar control could have been a pop-up with nothing but the calendar control, I showed you a way of getting the value of the control to the table.  
What I am saying now is that  if your ActiveX control has a control source property which you can set to the field SurveyDate, you do not need any buttons or code.  If it does not have a control source, then the Exit event should be able to run the code as you had written it.  I do not understand the error you reported.  Will it run in the Updated event instead?
0
 
dustyworkAuthor Commented:
Worked like a champ!  Thanks GRayL !!!
0
 
GRayLCommented:
Thanks, glad to help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now