Barcode procedure - problem with subform

M

Mackster

WindowsXP Pro, Access 2003. Wedge scanner with auto carriage return.

I have a form 'frm BARCODEDESTROY' based on a query 'qry BARCODEINPUT'. On
the form I have an unbound control 'BARCODEINPUT' with the following code:
-------Code Start-----------
Private Sub BARCODEINPUT_AfterUpdate()
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.BARCODEINPUT
If Not rsClone.NoMatch Then
Me.Bookmark = rsClone.Bookmark
' Change the item disposition to destroyed
Me.DISPOSITIO = "1"
End If
rsClone.CLOSE
End Sub
-------Code End-----------

This works fine and can scroll through bar code after bar code. The problem
comes in when I try to edit information in a subform 'EVMASTERsubform' which
is on the form. I tried the following code:
-------Code Start-----------
Private Sub BARCODEINPUT_AfterUpdate()
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.BARCODEINPUT
If Not rsClone.NoMatch Then
Me.Bookmark = rsClone.Bookmark
Me.DISPOSITIO = "1"
DoCmd.GoToControl "EVDETAIL SUBFORM"
DoCmd.GoToRecord , , acNewRec
[EVDETAIL SUBFORM]![REMOVED] = DATE
[EVDETAIL SUBFORM]![AGENCY] = Me.DEPNAME & " PER PRINTOUT"
[EVDETAIL SUBFORM]![REASON] = "DESTROYED"
End If
rsClone.CLOSE
End Sub
-------Code End-----------
This completely nullifies the original procedure and causes the form to go
to the next record in the database regardless of the barcode. I have tried
to add a setfocus for BARCODEINPUT, and a refresh command. I have also tried
to put the code in the control's BeforeUpdate procedure and add a Cancel=True
command to negate the auto-carriage return.

I have some special considerations for this database in that it is done with
a basHideAccessWindow function throughout so all forms are pop-up and modal.
I don't think this makes a difference, but in case it does....

Thanks in advance.
 
R

ruralguy via AccessMonster.com

Setting focus to a SubForm is a two step process. First you set the focus to
the SubFormControl and then you set the focus to a control on the SubForm.
And then there is that stubborn extra Form in the syntax.

Me.DISPOSITIO = "1"
Me![EVDETAIL SUBFORM].SetFocus
Me![EVDETAIL SUBFORM].Form!REMOVED.SetFocus
'-- DoCmd.GoToControl "EVDETAIL SUBFORM"
DoCmd.GoToRecord , , acNewRec
Me![EVDETAIL SUBFORM].Form![REMOVED] = DATE
Me![EVDETAIL SUBFORM].Form![AGENCY] = Me.DEPNAME & " PER PRINTOUT"
Me![EVDETAIL SUBFORM].Form![REASON] = "DESTROYED"

WindowsXP Pro, Access 2003. Wedge scanner with auto carriage return.

I have a form 'frm BARCODEDESTROY' based on a query 'qry BARCODEINPUT'. On
the form I have an unbound control 'BARCODEINPUT' with the following code:
-------Code Start-----------
Private Sub BARCODEINPUT_AfterUpdate()
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.BARCODEINPUT
If Not rsClone.NoMatch Then
Me.Bookmark = rsClone.Bookmark
' Change the item disposition to destroyed
Me.DISPOSITIO = "1"
End If
rsClone.CLOSE
End Sub
-------Code End-----------

This works fine and can scroll through bar code after bar code. The problem
comes in when I try to edit information in a subform 'EVMASTERsubform' which
is on the form. I tried the following code:
-------Code Start-----------
Private Sub BARCODEINPUT_AfterUpdate()
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.BARCODEINPUT
If Not rsClone.NoMatch Then
Me.Bookmark = rsClone.Bookmark
Me.DISPOSITIO = "1"
DoCmd.GoToControl "EVDETAIL SUBFORM"
DoCmd.GoToRecord , , acNewRec
[EVDETAIL SUBFORM]![REMOVED] = DATE
[EVDETAIL SUBFORM]![AGENCY] = Me.DEPNAME & " PER PRINTOUT"
[EVDETAIL SUBFORM]![REASON] = "DESTROYED"
End If
rsClone.CLOSE
End Sub
-------Code End-----------
This completely nullifies the original procedure and causes the form to go
to the next record in the database regardless of the barcode. I have tried
to add a setfocus for BARCODEINPUT, and a refresh command. I have also tried
to put the code in the control's BeforeUpdate procedure and add a Cancel=True
command to negate the auto-carriage return.

I have some special considerations for this database in that it is done with
a basHideAccessWindow function throughout so all forms are pop-up and modal.
I don't think this makes a difference, but in case it does....

Thanks in advance.
 
M

Mackster

Thank you - the extra 'Form' was my problem. The change you suggested works
perfectly.
--
I'm not young enough to know everything.


ruralguy via AccessMonster.com said:
Setting focus to a SubForm is a two step process. First you set the focus to
the SubFormControl and then you set the focus to a control on the SubForm.
And then there is that stubborn extra Form in the syntax.

Me.DISPOSITIO = "1"
Me![EVDETAIL SUBFORM].SetFocus
Me![EVDETAIL SUBFORM].Form!REMOVED.SetFocus
'-- DoCmd.GoToControl "EVDETAIL SUBFORM"
DoCmd.GoToRecord , , acNewRec
Me![EVDETAIL SUBFORM].Form![REMOVED] = DATE
Me![EVDETAIL SUBFORM].Form![AGENCY] = Me.DEPNAME & " PER PRINTOUT"
Me![EVDETAIL SUBFORM].Form![REASON] = "DESTROYED"

WindowsXP Pro, Access 2003. Wedge scanner with auto carriage return.

I have a form 'frm BARCODEDESTROY' based on a query 'qry BARCODEINPUT'. On
the form I have an unbound control 'BARCODEINPUT' with the following code:
-------Code Start-----------
Private Sub BARCODEINPUT_AfterUpdate()
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.BARCODEINPUT
If Not rsClone.NoMatch Then
Me.Bookmark = rsClone.Bookmark
' Change the item disposition to destroyed
Me.DISPOSITIO = "1"
End If
rsClone.CLOSE
End Sub
-------Code End-----------

This works fine and can scroll through bar code after bar code. The problem
comes in when I try to edit information in a subform 'EVMASTERsubform' which
is on the form. I tried the following code:
-------Code Start-----------
Private Sub BARCODEINPUT_AfterUpdate()
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.BARCODEINPUT
If Not rsClone.NoMatch Then
Me.Bookmark = rsClone.Bookmark
Me.DISPOSITIO = "1"
DoCmd.GoToControl "EVDETAIL SUBFORM"
DoCmd.GoToRecord , , acNewRec
[EVDETAIL SUBFORM]![REMOVED] = DATE
[EVDETAIL SUBFORM]![AGENCY] = Me.DEPNAME & " PER PRINTOUT"
[EVDETAIL SUBFORM]![REASON] = "DESTROYED"
End If
rsClone.CLOSE
End Sub
-------Code End-----------
This completely nullifies the original procedure and causes the form to go
to the next record in the database regardless of the barcode. I have tried
to add a setfocus for BARCODEINPUT, and a refresh command. I have also tried
to put the code in the control's BeforeUpdate procedure and add a Cancel=True
command to negate the auto-carriage return.

I have some special considerations for this database in that it is done with
a basHideAccessWindow function throughout so all forms are pop-up and modal.
I don't think this makes a difference, but in case it does....

Thanks in advance.
 
R

ruralguy via AccessMonster.com

You're welcome. Glad I could help.
Thank you - the extra 'Form' was my problem. The change you suggested works
perfectly.
Setting focus to a SubForm is a two step process. First you set the focus to
the SubFormControl and then you set the focus to a control on the SubForm.
[quoted text clipped - 58 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top