Bookmark Failing

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Code Problem - It stops on the - Me.Bookmark = rst.Bookmark. I can;t figure
out whats wrong. I have used this code before in other forms to do a lookup
and or add an item if it doesn't find the item. It is getting to this one
step and fails. Any ideas?

Private Sub cboAddItem_AfterUpdate()
On Error GoTo Err_cboAddItem_AfterUpdate

Dim SID As String
Dim rst As DAO.Recordset
Dim strCriteria As String

SID = Me.cboAddItem.Value
Set rst = Me.RecordsetClone
strCriteria = "[Item]=" & "'" & SID & "'"

rst.FindFirst strCriteria

If rst.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me.ITEM = Me.cboAddItem.Column(0)
Me.Refresh
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

Exit_cboAddItem_AfterUpdate:
Exit Sub

Err_cboAddItem_AfterUpdate:
MsgBox Err.DESCRIPTION
Resume Exit_cboAddItem_AfterUpdate

End Sub
 
J

JethroUK©

try:

rst.Movefirst

before

rst.FindFirst strCriteria

not sure, but i think it's the only way to ensure it starts looking from the
beginning
 
J

JethroUK©

or better:

with rst
.movelast
.movefirst
.findfirst srtcriteria
end with

it's a method of refreshing the dataset before you search (use it) & could
be the reason you are getting a bad bookmark


JethroUK© said:
try:

rst.Movefirst

before

rst.FindFirst strCriteria

not sure, but i think it's the only way to ensure it starts looking from the
beginning



mattc66 via AccessMonster.com said:
Code Problem - It stops on the - Me.Bookmark = rst.Bookmark. I can;t figure
out whats wrong. I have used this code before in other forms to do a lookup
and or add an item if it doesn't find the item. It is getting to this one
step and fails. Any ideas?

Private Sub cboAddItem_AfterUpdate()
On Error GoTo Err_cboAddItem_AfterUpdate

Dim SID As String
Dim rst As DAO.Recordset
Dim strCriteria As String

SID = Me.cboAddItem.Value
Set rst = Me.RecordsetClone
strCriteria = "[Item]=" & "'" & SID & "'"

rst.FindFirst strCriteria

If rst.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me.ITEM = Me.cboAddItem.Column(0)
Me.Refresh
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

Exit_cboAddItem_AfterUpdate:
Exit Sub

Err_cboAddItem_AfterUpdate:
MsgBox Err.DESCRIPTION
Resume Exit_cboAddItem_AfterUpdate

End Sub

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com
 
M

Marshall Barton

mattc66 said:
Code Problem - It stops on the - Me.Bookmark = rst.Bookmark. I can;t figure
out whats wrong. I have used this code before in other forms to do a lookup
and or add an item if it doesn't find the item. It is getting to this one
step and fails. Any ideas?

Private Sub cboAddItem_AfterUpdate()
On Error GoTo Err_cboAddItem_AfterUpdate

Dim SID As String
Dim rst As DAO.Recordset
Dim strCriteria As String

SID = Me.cboAddItem.Value
Set rst = Me.RecordsetClone
strCriteria = "[Item]=" & "'" & SID & "'"

rst.FindFirst strCriteria

If rst.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me.ITEM = Me.cboAddItem.Column(0)
Me.Refresh
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

Exit_cboAddItem_AfterUpdate:
Exit Sub

Err_cboAddItem_AfterUpdate:
MsgBox Err.DESCRIPTION
Resume Exit_cboAddItem_AfterUpdate

End Sub


Two things jump out as possible issues.

One is that if Item is a numeric type field, you need to get
rid of the quotes. Quotes are only used for Text fields.

The other possible issue is that Item is a reserved word and
may be confusing Access. Try changing the field name and
see if it helps.
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

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