help with a search feature

G

Guest

Allen,

I am wondering if you could help understand this a little more. I've tried
using this code you have written for my own database, but when I attempt to
go to a record, I get an error message reading: "Run-time error '438': Object
doesn't support this property or method" Then if I click 'debug' I'm taken
the the script and this line is highlighted: " strWhere = "[DocumentID] = " &
Me.Goto "

Why am I getting this error message? Is it because my field 'DocumentID' is
an AutoNumber?

And if so, is there another way this script is written when using AutoNumber
fields?

Thanks for any help.

-justin
--
I've never used Access before. HELP!


Allen Browne said:
Place an unbound text box (or combo if there aren't too many records) on
your form (e.g. in the Form Header section).

Name it "Goto".

Set its AfterUpdate property to
[Event Procedure]

Click the Build button (...) beside this.
Access opens the code window.
Paste the following in between the "Private Sub..." and "End Sub" lines:

Dim strWhere As String
If Me.Dirty Then 'Save before move.
Me.Dirty = False
End If
If Not IsNull(Me.Goto) Then
strWhere = "[NameOfYourIDFieldHere] = " & Me.Goto
With Me.RecordsetClone
.FindFirst strWhere
If .NoMatch Then
MsgBox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End With
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

GeorgeH said:
I use an autonumber to identify records. Is there a way to use that field
to
quickly search for records, much like you can enter the record number in
Access's build-in navigation tools to quickly jump to a desired record.
 
A

Allen Browne

This line looks fairly innocuous:
strWhere = "[DocumentID] = " & Me.Goto

If that fails with error 438, check what you have that is named Goto. Try
renaming the text box to txtGoto, and changing the code to:
strWhere = "[DocumentID] = " & Me.txtGoto

On the Debug menu, try Compile. This will let you know if there are other
problems with the code that need to be sorted out.

BTW, it's generally best to find the original question and post a followup
if you have a follow-on question.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

justin said:
Allen,

I am wondering if you could help understand this a little more. I've tried
using this code you have written for my own database, but when I attempt
to
go to a record, I get an error message reading: "Run-time error '438':
Object
doesn't support this property or method" Then if I click 'debug' I'm taken
the the script and this line is highlighted: " strWhere = "[DocumentID] =
" &
Me.Goto "

Why am I getting this error message? Is it because my field 'DocumentID'
is
an AutoNumber?

And if so, is there another way this script is written when using
AutoNumber
fields?

Thanks for any help.

-justin
--
I've never used Access before. HELP!


Allen Browne said:
Place an unbound text box (or combo if there aren't too many records) on
your form (e.g. in the Form Header section).

Name it "Goto".

Set its AfterUpdate property to
[Event Procedure]

Click the Build button (...) beside this.
Access opens the code window.
Paste the following in between the "Private Sub..." and "End Sub" lines:

Dim strWhere As String
If Me.Dirty Then 'Save before move.
Me.Dirty = False
End If
If Not IsNull(Me.Goto) Then
strWhere = "[NameOfYourIDFieldHere] = " & Me.Goto
With Me.RecordsetClone
.FindFirst strWhere
If .NoMatch Then
MsgBox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End With
End If

GeorgeH said:
I use an autonumber to identify records. Is there a way to use that
field
to
quickly search for records, much like you can enter the record number
in
Access's build-in navigation tools to quickly jump to a desired record.
 
G

Guest

" BTW, it's generally best to find the original question and post a followup
if you have a follow-on question."


I did do this, I just thought since the post was from 2004 nobody would see
it, so I just made a new one.

Thanks for the help, I'll have to try this.








--
I've never used Access before. HELP!


Allen Browne said:
This line looks fairly innocuous:
strWhere = "[DocumentID] = " & Me.Goto

If that fails with error 438, check what you have that is named Goto. Try
renaming the text box to txtGoto, and changing the code to:
strWhere = "[DocumentID] = " & Me.txtGoto

On the Debug menu, try Compile. This will let you know if there are other
problems with the code that need to be sorted out.

BTW, it's generally best to find the original question and post a followup
if you have a follow-on question.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

justin said:
Allen,

I am wondering if you could help understand this a little more. I've tried
using this code you have written for my own database, but when I attempt
to
go to a record, I get an error message reading: "Run-time error '438':
Object
doesn't support this property or method" Then if I click 'debug' I'm taken
the the script and this line is highlighted: " strWhere = "[DocumentID] =
" &
Me.Goto "

Why am I getting this error message? Is it because my field 'DocumentID'
is
an AutoNumber?

And if so, is there another way this script is written when using
AutoNumber
fields?

Thanks for any help.

-justin
--
I've never used Access before. HELP!


Allen Browne said:
Place an unbound text box (or combo if there aren't too many records) on
your form (e.g. in the Form Header section).

Name it "Goto".

Set its AfterUpdate property to
[Event Procedure]

Click the Build button (...) beside this.
Access opens the code window.
Paste the following in between the "Private Sub..." and "End Sub" lines:

Dim strWhere As String
If Me.Dirty Then 'Save before move.
Me.Dirty = False
End If
If Not IsNull(Me.Goto) Then
strWhere = "[NameOfYourIDFieldHere] = " & Me.Goto
With Me.RecordsetClone
.FindFirst strWhere
If .NoMatch Then
MsgBox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End With
End If

I use an autonumber to identify records. Is there a way to use that
field
to
quickly search for records, much like you can enter the record number
in
Access's build-in navigation tools to quickly jump to a desired record.
 
A

Allen Browne

Good night! 2004.

Quite right, Justin: that message won't be on the servers any more.
 

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