Unique, one-time data, programflow in Acces

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zaankanter
    New Member
    • Feb 2008
    • 30

    Unique, one-time data, programflow in Acces

    Hi,

    This my problem.
    After distribution of my acces-application I want the new user to be able to enter his Name-adress-etc values, in a one-row table called program-variables. These will be used tot print on reports etc.
    I want this to be a one-time event. This will help to avoid illegal re-distibution.
    My idea is that before updating the values ther is a check: are the fields null or not?
    If not the action should be canceled.
    In more general terms the question is: how can I make the programflow in acces condional to the contents of a field in a table?

    I'm what you would call an advanced user of Acces, but have little knowledge of VB.
    Can anyone give me directions?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by zaankanter
    Hi,

    This my problem.
    After distribution of my acces-application I want the new user to be able to enter his Name-adress-etc values, in a one-row table called program-variables. These will be used tot print on reports etc.
    I want this to be a one-time event. This will help to avoid illegal re-distibution.
    My idea is that before updating the values ther is a check: are the fields null or not?
    If not the action should be canceled.
    In more general terms the question is: how can I make the programflow in acces condional to the contents of a field in a table?

    I'm what you would call an advanced user of Access, but have little knowledge of VB.
    Can anyone give me directions?
    Assuming you have a Form Interface for entering this information, then in the BeforeUpdate() Event of the Form, enter code similar to the following:
    [CODE=vb]
    Private Sub Form_BeforeUpda te(Cancel As Integer)
    If IsNull(Me![txtFirstName]) Then
    MsgBox "You must enter your First Name"
    Cancel = True
    ElseIf IsNull(Me![txtLastName]) Then
    MsgBox "You must enter your Last Name"
    Cancel = True
    ElseIf IsNull(Me![txtAddress]) Then
    MsgBox "Forgot our Address, did we?"
    Cancel = True
    Else
    'Assuming your Form is not Bound to program-variables
    Dim MyDB As DAO.Database, MyRS As DAO.Recordset
    Set MyDB = CurrentDb
    Set MyRS = MyDB.OpenRecord set("program-variables", dbOpenTable)
    With MyRS
    .AddNew
    MyRS![First Name] = Me![txtFirstName]
    MyRS![Last Name] = Me![txtLastName]
    MyRS![Address] = Me![txtAddress]
    .Update
    End With
    MyRS.Close: Set MyRS = Nothing

    MsgBox "Record saved for " & Me![txtFirstName] & " " & Me![txtLastName]
    End If
    End Sub[/CODE]
    NOTE: Don't forget that you must make provisions to see if the individual has already been added to program-variables before you ever Open this User Info Form. Please be advised that if you have any further questions, I'll be on vacation and will not be able to reply, but I'm sure that we will have many others willing to assist you.

    Comment

    • zaankanter
      New Member
      • Feb 2008
      • 30

      #3
      Sorry to answer so late, I was incorrectly under the impression that any answer to my post would by announced by an email.
      I'm very glad to recieve such an elaborate answer.
      Will look at it first thing tomorrow (its past 00.00 local time now).
      Wil let you know what my findings are.

      Comment

      • zaankanter
        New Member
        • Feb 2008
        • 30

        #4
        This is not what I was looking for. Probably didn't formulate my question right. I'll try again.
        On opening my acces-application, an opening-form is shown with a "start"-button, wich leads to te rest of the application.
        However, when the application is not yet been used for the first time, I want the "start"-button to lead to a form where Name-adres-etc values are to be given.
        The next time the application is used I do not want this to happen, but I want the "start"-button to lead directly tot the rest of the program. In this way there is only a one-time event in wich the user identify's himself to the program. It is now dedicated to him and is useless to other would-be users.

        So, I want the routine in/under the "start"-button to check: Have the fields for name-adres-etc already been filled? Yes: go on to the main program. No: open the name-adres form.
        Or, in other words: How do I make the response of button (or another user-driven event) conditional to the contents of a specific field in a table?
        Hope I'm more intelligable now?

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by zaankanter
          This is not what I was looking for. Probably didn't formulate my question right. I'll try again.
          On opening my acces-application, an opening-form is shown with a "start"-button, wich leads to te rest of the application.
          However, when the application is not yet been used for the first time, I want the "start"-button to lead to a form where Name-adres-etc values are to be given.
          The next time the application is used I do not want this to happen, but I want the "start"-button to lead directly tot the rest of the program. In this way there is only a one-time event in wich the user identify's himself to the program. It is now dedicated to him and is useless to other would-be users.

          So, I want the routine in/under the "start"-button to check: Have the fields for name-adres-etc already been filled? Yes: go on to the main program. No: open the name-adres form.
          Or, in other words: How do I make the response of button (or another user-driven event) conditional to the contents of a specific field in a table?
          Hope I'm more intelligable now?
          The following code, placed in the Click() Event of a Command Button, will check and see if a First Name exists in tblUserInfo. tblUserInfo will consist of a [First], [Last], and [Address] Field all of which are Required, so either it contains a Record or it doesn't. No need to check the existence of all three Fields. If a value exists, open a fictitious Main Form, if it doesn't open a fictitious Name/Address Form. When I have shown you is just simply a broad guideline, more like pseudo code:
          [CODE=vb]
          Private Sub cmdStart_Click( )
          On Error GoTo Err_cmdStart_Cl ick

          If IsNull(DLookup( "[First]", "tblUserInf o")) Then
          DoCmd.OpenForm "frmNameAddress ", acNormal, , , acFormAdd, acWindowNormal
          Else
          DoCmd.OpenForm "frmMainProgram ", acNormal, , , acFormEdit, acWindowNormal
          End If

          Exit_cmdStart_C lick:
          Exit Sub

          Err_cmdStart_Cl ick:
          MsgBox Err.Description , vbExclamation, "Error in cmdStart_Click( )"
          Resume Exit_cmdStart_C lick
          End Sub[/CODE]
          Is this the correct interpretation?

          Comment

          • zaankanter
            New Member
            • Feb 2008
            • 30

            #6
            You are the greatest !
            May be it's simple to you, but for me its magic.
            After changíng the names of the tables etc its works like a swiss clock !
            Just proves to me that I should do some serious study of VB...

            Thanks.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by zaankanter
              You are the greatest !
              May be it's simple to you, but for me its magic.
              After changíng the names of the tables etc its works like a swiss clock !
              Just proves to me that I should do some serious study of VB...

              Thanks.
              Glad it worked out for you.

              Comment

              Working...