Results 1 to 14 of 14
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Location
    Pendleton, Indiana, USA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Retrieving a value from Active X Com. (2000)

    I was wondering about retrieving a value from Active X Com. I have inserted a combo box and a Active X Calendar. I want to insert the values from the combo box and the calendar into a table. I can get the combo box information, but how can I retreive the date(value) selected on the calendar. Thank you.

    Trent

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    If you used the Calendar Control that comes with Access, the Value property of the control should return the selected date, and even referring to the name of the calendat control itself, without specifying a property, should do so, since Value is the default property.

    If you prefer, you can also refer to the Day, Month and Year properties of the calendar control.

  3. #3
    Star Lounger
    Join Date
    Sep 2002
    Location
    Pendleton, Indiana, USA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving a value from Active X Com. (2000)

    OK if I was to create a button to add a record to a table with the combo box value and calendar value, how do I refer to the value of the calendar. I'm trying to learn some more ways to use Access, and this forum is great place for help. Oh yes it is the object that came with Access. Thanks alot for all your help Hans.

    Trent

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    Open your form in design view and click on the calendar control. You will see the name of this control in the Controls box on the Formatting toolbar, and in the title bar of the Properties window. If you haven't renamed it, it'll probably be called Calendar0 or something like that; let's use that name for illustration purposes. In your code, you would just refer to Calendar0 or to Calendar0.Value. Both will evaluate to the date selected by the user in the calendar; by default that will be today's date.

    Private Sub cmdTest_Click()
    MsgBox "You selected " & Calendar0.Value
    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    Is the form that houses the combo box and calendar control bound to the table you want to add a record to, or is it unbound?

    If it is bound, you only have to set the control source of the combo box and calendar control to the appropriate fields. If it is not bound, you can use ADO or DAO to insert a record in the table. Here is an example using ADO (you need a reference to Microsoft ActiveX Data Objects 2.n Library - check Tools | References... in the Visual Basic Editor).

    Private Sub cmdAdd_Click()
    Dim cnn As ADODB.Connection
    Dim rst As New ADODB.Recordset
    Set cnn = CurrentProject.Connection
    rst.CursorType = adOpenKeyset
    rst.LockType = adLockOptimistic
    rst.Open "tblSomething", cnn, , , adCmdTable
    rst.AddNew
    rst!ID = cbx
    rst!D = Calendar0
    rst.Update
    rst.Close
    Set rst = Nothing
    Set cnn = Nothing
    End Sub

    Of course, you must replace the names of the table, combo box and calendar control by the ones you have.

  6. #6
    Star Lounger
    Join Date
    Sep 2002
    Location
    Pendleton, Indiana, USA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving a value from Active X Com. (2000)

    I don't know VB, but I did as you said and it still does not update. I attached the code. Don't mean to be a pain. thanks

    Trent
    Attached Images Attached Images

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    You say "it does not update". What is it? The table or the form? If you need this code, the form is not bound to any table, I suppose, so the form does not need to be updated. If the form *is* bound to the Paid table, you don't need this code. So please state clearly what the situation is.

  8. #8
    Star Lounger
    Join Date
    Sep 2002
    Location
    Pendleton, Indiana, USA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving a value from Active X Com. (2000)

    The form is not bound. The table needs to be updated, the table does not update the two fields in the Paid table. (there is a 3rd field ID and it is a autonumber and the Key). If the form was bound to the Paid table would that make it easier to do, and would that limit any other functions.

    Trent

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    If the table does not get updated, do you get an error message?

    I tested the code on a simple demo; it worked there without problems, so there must be something specific. The problem shouldn't be in the AutoNumber field - that should be filled automatically. You try to fill FullName from the combo box. Does the bound column of the combo box refer to a name field, or perhaps to a numeric key field?

  10. #10
    Star Lounger
    Join Date
    Sep 2002
    Location
    Pendleton, Indiana, USA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving a value from Active X Com. (2000)

    No error message @ all. The combo box is unbound, it is populated by a query (select....). The query combines First Name and Last Name to a FullName field and then the combo box is then populated from that. Really I'm not trying to be difficult, just trying to learn.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    I'm stumped for the moment. I would expect ADO to throw an error message at you if it can't add a record to the table, so I don't understand what's happening.

    One other thing you can try is to rename the Date field to something else both in the table and in the code. Date is a VBA function and a data type, so using it as a field name may cause problems.

    If that doesn't work, I am afraid we're not going to get much further with this without seeing the database. Perhaps you could attach a stripped down version of the database to a post.
    <UL><LI>Make a copy of the database and work with that.
    <LI>Remove all database objects that are not relevant to the problem.
    <LI>In the remaining table(s), remove most records - leave only the minimum number necessary to demonstrate the problem.
    <LI>Remove or modify data of a confidential nature.
    <LI>Do a compact and repair (Tools/Database Utilities).
    <LI>Make a zip file containing the database; it should be below 100KB.
    <LI>Attach the zip file to a reply.[/list]

  12. #12
    Star Lounger
    Join Date
    Sep 2002
    Location
    Pendleton, Indiana, USA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving a value from Active X Com. (2000)

    I have compacted it, and tried changing a few things. Didn't help.
    Attached Files Attached Files

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving a value from Active X Com. (2000)

    The command button on the form has an empty On_Click procedure. There is an On_Click procedure in the form module that *does* contain the correct code, but it is for a non-existing button. Moving this code to the empty On_Click procedure is enough to make it work.

  14. #14
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Retrieving a value from Active X Com. (2000)

    ADO returns a lot of errors to the connection's errors collection and fails silently unless you loop through that collection to examine it. I've seen this a lot, although I've had others tell me it never happens. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •