Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    42

    Unanswered: Checkbox & Update Query

    Ok...round two. This one should be easier than the last one.

    I got the status field to update depending on the date fields. Now I need the date field to autoupdate when a checkbox is checked. I have two queries, one adds the date if the box is checked, and the second removes it if they change their minds and uncheck the box.

    CheckboxName: PACheck

    Query1:

    Fieldname (Trying to change):PADate
    Table: 00-CostRed
    UpdateTo: [PADate]=Now()
    Criteria (Record No): [Forms]![00_02_03-CRWorksheet]![CRID]


    Query2:

    Fieldname (Trying to change):PADate
    Table: 00-CostRed
    UpdateTo: [PADate]=Null
    Criteria (Record No): [Forms]![00_02_03-CRWorksheet]![CRID]

    This is all one Macro that runs those queries depending on the checkbox(On Click for checkbox PA):

    MacroName: PACheckbox
    Condition1: [Forms]![00_02_03-CRWorksheet]![PACheck]=Yes
    MsgBox:
    OpenQuery: Query1
    Requery: PADate
    Condition2: [Forms]![00_02_03-CRWorksheet]![PACheck]=No
    MsgBox:
    OpenQuery: Query2
    Requery: PADate

    When I click I get no changes, but the message boxes do appear as appropriate (off=query 2, on=query 1), but the update queries never write the data over to the PADate field and Im not sure why.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    can't help with macros.
    do you have (or can you put) [PAdate] on your form? if yes:

    Code:
    private sub PAcheck_afterupdate()
    	if PAcheck.value then
    		PAdate.value = now()
    	else
    		PAdate.value = null
    	endif
    end sub
    izy
    Last edited by izyrider; 07-27-03 at 13:23.

  3. #3
    Join Date
    Jul 2003
    Posts
    42

    sounds too easy

    K dont laugh but Im not sure where to put that text. How do I put the code in there? I have seen the vb on buttons through expressions but I am not sure how to put it in a text box that contains data and secondly how do I get that info to a query or table for reporting purposes?

  4. #4
    Join Date
    Jul 2003
    Posts
    42

    ok ignore the where to put part

    I put it in under the Onclick for the checkbox and this works great. You are amazing. Writing code seems a heck of a lot easier than the macros. I have new vb book I plan to sit down with tonight. Thanks again.

Posting Permissions

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