Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    89

    Unanswered: Need auto inserted info to be saved.

    Hi

    Can some1 help me i have to sub forms.

    1. where info is inserted to a tabel. (called: frmINPUT)

    2. where the people can choose there name of who is inserting the info. (caled:frmINFO)

    I have the code to get the name from frmINPUT to frmINFO
    Forms![frmINPUT].[nameINPUT].Value = nameINFO.Value
    But now i want the value from the frmNAME.nameINPUT not to become blank when the Record on that is inserted on frmINFIO is saved.

    In overal i want every record an name in it from who it has inserted.

  2. #2
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    I hope I'm understanding your question correctly... You could use a variable to hold the value and set the text box to the variable in the On Current event of form. However, there are a few situations to be aware of since the On Current event is triggered for new and existing records:

    • You have to check if a value already exists so you don't overwrite what's already there.
    • I'd make that field required in the database so this user doesn't get tagged to an existing record just for viewing it. (if the value is null for an existing record and you have it set to fill in the value on current, the current User will be tagged as the creator of that record)

    But if you pay attention to your design, you could declare a variable to be used within the form:

    dim currentUser as String
    currentUser = ""

    Then when they choose a user just set this variable to that value. And in the On Current event set the text box to this value. The nz() functions are just to ensure that a value doesn't already exist in the form


    Code:
    Private Sub Form_Current()
        If (Nz(nameINPUT.Value, "") = "") Then
            nameINPUT.Value = Nz(CurrentUser, "")
        End If
    End Sub
    There are other (and possibly better) ways to do this but this is what came to mind today

    Steve

Posting Permissions

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