Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107

    Unanswered: Presetting default values

    Hello all,

    in an actual project i created a generic form for table editing (see attached pic). It loads the table given as FormOpenArg into a SubForm. Additionally default filters (here Statement and SAccount) can be set. In case the filter is a drop down list (not a like filter) the filtered fields are hidden from the UI. If such a filter is set i have to preset the field with the filtered value when creating a new record. Setting the default value of the TableDef doesn't seem to work as it doesn't apply to the open instance in the form. Neither does setting the default value of the field in the SubForm work properly.

    Any idea?
    Attached Thumbnails Attached Thumbnails fedGeneric.JPG  

  2. #2
    Join Date
    Feb 2006
    Posts
    56
    not sure if you are doing this via a macro or code. I see that you are also using a datasheet view as the form design. If you used a regular form with textboxes and the like, you could write code to preset the value or set the default value. In code, you could do something like this


    Private Sub Text00_BeforeUpdate(Cancel As Integer)
    If rs.field = value1 then
    me.text.00.text = something
    elseif rs.field = value2 then
    me.text00.text= something else
    else
    me.text00.text = something else
    end if

    hope this helps. sorry, I am only able to spend a couple of minutes on this.

    John

  3. #3
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107

    not really

    thanks JF,

    the form is intended to be a generic edit form. the table displayed is defined by a parameter. it's to avoid a edit form for each and every table (works fine so far). btw - everythin is done in code not via macro. the only thing missing is the default value for the hidden fields (defined by the dropdown filters in the header).

  4. #4
    Join Date
    Feb 2006
    Posts
    56
    ok then I would recommend what I posted last time. set the following based upon the selection: me.text1.defaultvalue = "somevalue" or me.text1.text = "somevalue" in the afterupdate event of the combofilter.

    Thanks,

    John

  5. #5
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107

    still not

    tried that before .. doesn't seem to work

    was trying
    - SubForm.Controls(FieldName).DefaultValue
    - SubForm.Form.RecordSet.Fields(FieldName).DefaultVa lue
    both show no effect when adding a new record (using MS Access 2002)

    usin the TableDef Object would only be a possibility when closin the SourceObject in the SubForm and reopening it.

  6. #6
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107

    solved

    solved it on my own

    instead of using an unbound form .. both forms (container and subform) have the same table as source. the outer form is filtered and the subform is bound to the outer one - and the defaults are set automatically by access.

    thanks JF

Posting Permissions

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