Close Form and update record in Table on field change

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gerald Taylor
    New Member
    • Apr 2012
    • 2

    Close Form and update record in Table on field change

    Please excuse any idiotic questions as Access/VBA is a new area to me.
    I have inherited an Access Database/Application that is used to sign in and out visitors and Staff to our community Centre.
    The system works fine and with the addition of extra screens(forms) we have managed to get it to work using touchscreen monitor and an OSK.
    I was looking at using a Barcode Font (Free 3 of 9 Extended)to simplify signing in and out for Staff, and also so we are not showing list of signed in people on screen.
    So how it works.
    A visitor or staff member is presented with a screen offering choice of Visitor or Staff Member, whichever choice is made takes it to another screen (Form) that asks to sign in or Sign out.
    In the Sign Out section a Staff Member Scans their ID badge (with Barcode and Numeric Staff ID) the form has an Unbound Text Box which has Focus when the Form is opened, after scanning ID Badge the next field (FullName) is Populated with The Staff ID No from Badge Barcode using a Search Record Macro with Control source [BadgeID], this then brings up the previous record from when they Signed in.
    So Far so good. But this is where I am lost, I have a close Buttton (toggle Button) on the Form which closes the form but the record in the Table does not alter. The form is bound to table VisitorSigninOu t. I have a Field in the Table called SignedOut and a Field called TimeOut, when the Form is opened in Edit mode these are the two fields on the form that are not on the Sign In form so I thought they would be added to the earlier record, but they don't. However if I assign the Control Source of the Toggle button as SignedOut the records are updated and we can see Visitor or staff in and out times. I guess this is incorrect way of doing this but it works. I could leave like this but what I would like to do is to have the Staff member go to the Sign Out form , pass their badge under the scanner and when their record appears for the form to update the record and close the form automatically. At the moment I am using Macros and wizards as I am a total non starter with VBA.
    Any pointers or help is appreciated.
  • Gerald Taylor
    New Member
    • Apr 2012
    • 2

    #2
    Excuse my Error in the Paragraph under 'How it Works'
    The correct method is A staff Member gets to the 'sign out form' then passes their ID Badge under Barcode Scanner, Field 1 (unbound)(attac hed is a Macro in 'before Update property' of field to Search for Record based on Badge ID No which is showing after scan) displays their Staff ID number and the Next Field FullName (bound to FullName control Source)and (Macro to requery) shows Staff Member name from Sign In record, not Badge ID as I posted.

    Comment

    • Mihail
      Contributor
      • Apr 2011
      • 759

      #3
      Too long explanation for my English.
      Code:
      Option Compare Database
      Option Explicit
      
      Private Sub Button_Click()
      'This will save the record if necessary (if the record has been modifyed
          If Me.Dirty Then Me.Dirty = False
          
      'This force to save the record
          DoCmd.RunCommand acCmdSaveRecord
          
      'This will close the form
          DoCmd.Close acForm, "FormName"
      ''Or you can use
          'DoCmd.Close acForm, Me.Name
      End Sub

      Comment

      Working...