input form for a scan gun

krberube

just beyond new
Local time
Today, 07:33
Joined
Jan 14, 2005
Messages
142
Good morning all,
I have a form used for dataentry from a scangun. 4 field A, B, C, D. A = an unbound text field, where I want all the scanning to go on. I have code to check the value of what is scanned and move it to either B, C, or D, based on a prefix. no problem there.

Question 1: If no prefix matches then go back to field A for another scan, I need it to overwrite the old data that was scanned in. not sure how to do this.

Question 2: once all 3 fields B, C, D are no longer null move to the next record.

could you take a look at my code ( still new to VBA) and maybe help out alittle?
Thanks
Kevin

Private Sub Text14_AfterUpdate()
Dim I
inputloop:
Forms![FRM_SLA Back]!Text14.SetFocus
If Me.Text14 Like "DH*" Then
Me.PSSN = Me.Text14
ElseIf Me.Text14 Like "AC*" Then
Me.MBSN = Me.Text14
ElseIf Me.Text14 Like "BB*" Then
Me.SLABack = Me.Text14
Else
For I = 1 To 3
Beep 100, 150
Next I
Forms![FRM_SLA Back]!Text14.SetFocus
End If

If Me.PSSN = Null Then
GoTo inputloop
ElseIf Me.MBSN = Null Then
GoTo inputloop
ElseIf Me.SLABack = Null Then
GoTo inputloop
End If

End Sub
 
ok, lets try this. The only problem i now have is checking that all 3 fields are filled in. if they are i need to move to a new record to start over again.

Thanks
Kevin
 
maybe this. I think i have a better way of placing the scanned data into the correct fields and eliminating bad scans. see below. I still can't figure out how to check if the 3 fields are populated and move to a new record to begin again.

Private Sub A_AfterUpdate()
Dim I
Dim scan As Variant

inputloop:
Me.A.SetFocus
scan = Left$(Forms!CopyofFRM_SLABack.A, 2)
Select Case scan
Case Is = "DH"
If IsNull(Me.B) Then
Me.B = Me.A
Else
Me.A.SetFocus
Beep 280, 280
End If
Case Is = "BB"
If IsNull(Me.C) Then
Me.C = Me.A
Else
Me.A.SetFocus
Beep 280, 280
End If
Case Is = "AC"
If IsNull(Me.D) Then
Me.D = Me.A
Else
Me.A.SetFocus
Beep 280, 280
End If
Case Else
Me.A.SetFocus
For I = 1 To 3
Beep 100, 100
Me.A.SetFocus
Next I
End Select
End Sub
 
Maybe something like this

Maybe you can try something like this. Also, it is hard because I don't know how you have your record source set up or what your form looks like.

Code:
Dim I As Byte

inputloop:
    Text14.SetFocus
        If Text14 Like "DH*" Then
            txtPSSN = Text14
        ElseIf Text14 Like "AC*" Then
            txtMBSN = Text14
        ElseIf Text14 Like "BB*" Then
            txtSLABack = Text14
        Else
            For I = 1 To 3
                Beep
            Next I
        Text14 = ""
        End If
'<----------If any are null then it goes back to input.
'                Otherwise, It will make sure all are Not Null
'                and save the record and then move to the
'<----------next one.
If txtPSSN = Null Or txtMBSN = Null Or txtSLABack = Null Then
    GoTo inputloop
ElseIf txtPSSN <> Null And txtMBSN <> Null And txtSLABack <> Null Then
    Me.Requery
    Me.RecordsetClone.MoveNext
End If

Again, I haven't really tested this.

Scott
 
hi all,
I have tried a few things with RobertScotts post and still can't get it to go to a new record. below is the code i currently have with an attachment of my form.
Would appreciate any help on moveing to a new record when all 3 fields are filled in.
Thanks
Kevin

Private Sub Text14_AfterUpdate()
Dim I
Dim scan As Variant

inputloop:
Me.Text14.SetFocus
scan = Left$(Forms!CopyofFRM_SLABack.Text14, 2)
Select Case scan
Case Is = "DH"
If IsNull(Me.PSSN) Then
Me.PSSN = Me.Text14
Else
Me.Text14.SetFocus
'Beep 280, 280
End If
Case Is = "BB"
If IsNull(Me.SLABack) Then
Me.SLABack = Me.Text14
Else
Me.Text14.SetFocus
'Beep 280, 280
End If
Case Is = "AC"
If IsNull(Me.MBSN) Then
Me.MBSN = Me.Text14
Else
Me.Text14.SetFocus
'Beep 280, 280
End If
Case Else
Me.Text14.SetFocus
For I = 1 To 3
'Beep 100, 100
Me.Text14.SetFocus
Next I
End Select

If txtPSSN = Null Or txtMBSN = Null Or txtSLABack = Null Then
GoTo inputloop
ElseIf txtPSSN <> Null And txtMBSN <> Null And txtSLABack <> Null Then
Me.Requery
DoCmd.GoToRecord , CopyofFRM_SLABack, acNewRec
End If

End Sub
 

Attachments

  • form.jpg
    form.jpg
    14.1 KB · Views: 184
I started toying with using a select case (BELOW) to analize a "value" that gets incremented each time 1 of the 3 fields is filled in and when the "value = 3" then goto a new record, but thats not working either. Is it because my "check" value keeps getting reset to "0"?

any other thoughts?


Private Sub Text14_AfterUpdate()
Dim I
Dim scan As Variant
Dim check As Integer
check = 0

Select Case check
Case Is = 1
GoTo inputloop
Case Is = 2
GoTo inputloop
Case Is = 3

End Select

inputloop:
Me.Text14.SetFocus
scan = Left$(Forms!CopyofFRM_SLABack.Text14, 2)
Select Case scan
Case Is = "DH"
If IsNull(Me.PSSN) Then
Me.PSSN = Me.Text14
check = check + 1
Else
Me.Text14.SetFocus
'Beep 280, 280
End If
Case Is = "BB"
If IsNull(Me.SLABack) Then
Me.SLABack = Me.Text14
check = check + 1
Else
Me.Text14.SetFocus
'Beep 280, 280
End If
Case Is = "AC"
If IsNull(Me.MBSN) Then
Me.MBSN = Me.Text14
check = check + 1
Else
Me.Text14.SetFocus
'Beep 280, 280
End If
Case Else
Me.Text14.SetFocus
For I = 1 To 3
'Beep 100, 100
Me.Text14.SetFocus
Next I
End Select

Me.Text14.Value = ""

End Sub
 
well, i think i have it down now. not sure i like doing data entry blind but this is what the bossman wants.
incase someone else needs it, here it is.

Private Sub Text14_afterUpdate()
Dim I
Dim scan As Variant

inputloop:
Me.Text14.SetFocus
scan = Left$(Forms!CopyofFRM_SLABack.Text14, 2)
Select Case scan
Case Is = "DH"
If IsNull(Me.PSSN) Then
Me.PSSN = Me.Text14
Else
Me.Text14.SetFocus
Beep 280, 280
End If
Case Is = "BB"
If IsNull(Me.SLABack) Then
Me.SLABack = Me.Text14
Else
Me.Text14.SetFocus
Beep 280, 280
End If
Case Is = "AC"
If IsNull(Me.MBSN) Then
Me.MBSN = Me.Text14
Else
Me.Text14.SetFocus
Beep 280, 280
End If
Case Else
Me.Text14.SetFocus
For I = 1 To 3
Beep 100, 100
Me.Text14.SetFocus
Next I
End Select

If Not IsNull(PSSN) And Not IsNull(MBSN) And Not IsNull(SLABack) Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , CopyofFRM_SLABack, acNewRec
Beep 400, 400
Me.Text14.Value = ""
Else
Me.Text14.Value = ""
Me.Text14.SetFocus
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom