how to save the textbox content to table field?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ayarowji
    Banned
    New Member
    • Aug 2010
    • 2

    #1

    how to save the textbox content to table field?

    how to save the textbox content to table field?
    For example: i have a form name form1, in this form it has a textboxes name Doc No, Number & Date
    In Table, my table name is table1, and field names; Doc No & Date
    If the textbox Doc No has a controlsource of =Date() & "-" & Format([ID],"000")
    the output of textbox Doc No is 080510-001
    how can i save this doc no to my table1?

    thnx,

    ayarowji
  • Steven Kogan
    Recognized Expert New Member
    • Jul 2010
    • 107

    #2
    The textbox Doc No contains a calculation, instead of being bound to the Doc No field. That could get confusing.

    First I'd rename the textbox Doc No to Doc No Calculated.

    Now you need to decide what event will cause Doc No Calculated to be entered into the Doc No field.

    VBA code to put Doc No Calculated into the Doc No field would be:

    Code:
    me.[Doc No] = me.[Doc No Calculated]
    The end solution will probably be more complicated...

    Perhaps you want Doc No to be filled in only if it is currently blank, in which case the code would be:
    Code:
    If nz([Doc No],"")="" Then[INDENT]me.[Doc No] = me.[Doc No Calculated][/INDENT]
    End If
    That code might go in the form's before update event, depending on your situation.

    Comment

    Working...