473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Quick search in Access database

I have a form with a field "RecNo". In stead if using "Ctrl F" and
type a number I would like to use a seperate field on the form where
you just type in the number and push enter. You should then jump
directly to this record.

Can anyone tell me how I can do this??
Nov 12 '05 #1
5 3859
Assuming that RecNo is a Number type field (not Text), put text box on your
form and give it these properties:
ControlSource {leave this blank!}
Format General Number
Name txtFindRecNo
After Update [Event Procedure]

Then click the Build button (...) beside After Update.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, enter this:

Dim strWhere As String
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record."
Else
strWhere = "[RecNo] = " & Nz(Me.RecNo, 0)
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.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter" <pi*************@hotmail.com> wrote in message
news:b8**************************@posting.google.c om...
I have a form with a field "RecNo". In stead if using "Ctrl F" and
type a number I would like to use a seperate field on the form where
you just type in the number and push enter. You should then jump
directly to this record.

Can anyone tell me how I can do this??

Nov 12 '05 #2
That looks a bit complicated Allen, why not a simple unbound combo box
called "FindIt" with the rowsource something like
SELECT RecNo FROM MyTable ORDER BY RecNo
and the AfterUpdate event as

Private Sub FindIt_AfterUpdate()

DoCmd.GoToControl "RecNo"
DoCmd.FindRecord FindIt

End Sub

Phil

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
Assuming that RecNo is a Number type field (not Text), put text box on your form and give it these properties:
ControlSource {leave this blank!}
Format General Number
Name txtFindRecNo
After Update [Event Procedure]

Then click the Build button (...) beside After Update.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, enter this:

Dim strWhere As String
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record."
Else
strWhere = "[RecNo] = " & Nz(Me.RecNo, 0)
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.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter" <pi*************@hotmail.com> wrote in message
news:b8**************************@posting.google.c om...
I have a form with a field "RecNo". In stead if using "Ctrl F" and
type a number I would like to use a seperate field on the form where
you just type in the number and push enter. You should then jump
directly to this record.

Can anyone tell me how I can do this??


Nov 12 '05 #3
Allen Browne wrote:
Assuming that RecNo is a Number type field (not Text), put text box on your
form and give it these properties:
ControlSource {leave this blank!}
Format General Number
Name txtFindRecNo
After Update [Event Procedure]

Then click the Build button (...) beside After Update.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, enter this:

Dim strWhere As String
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record."
Else
strWhere = "[RecNo] = " & Nz(Me.RecNo, 0)
'minor correction. I think it should be
strWhere = "[RecNo] = " & Nz(txtFindRecNo, 0)
With Me.RecordsetClone
.FindFirst strWhere
If .NoMatch Then
MsgBox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End With
End If


Nov 12 '05 #4
1. FindRecord cannot notify you whether it succeeded or not.

2. Before it can move, Access must save the current record. We have found
that doing that explicity avoids a range of issues.

3. What did you expect your code to do if the user updates FindIt to a blank
(e.g. entering something and backspacing it out)?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Phil Stanton" <di********@stantonfamily.co.uk> wrote in message
news:40***********************@mercury.nildram.net ...
That looks a bit complicated Allen, why not a simple unbound combo box
called "FindIt" with the rowsource something like
SELECT RecNo FROM MyTable ORDER BY RecNo
and the AfterUpdate event as

Private Sub FindIt_AfterUpdate()

DoCmd.GoToControl "RecNo"
DoCmd.FindRecord FindIt

End Sub

Phil

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
Assuming that RecNo is a Number type field (not Text), put text box on

your
form and give it these properties:
ControlSource {leave this blank!}
Format General Number
Name txtFindRecNo
After Update [Event Procedure]

Then click the Build button (...) beside After Update.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, enter this:

Dim strWhere As String
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record."
Else
strWhere = "[RecNo] = " & Nz(Me.RecNo, 0)
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.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter" <pi*************@hotmail.com> wrote in message
news:b8**************************@posting.google.c om...
I have a form with a field "RecNo". In stead if using "Ctrl F" and
type a number I would like to use a seperate field on the form where
you just type in the number and push enter. You should then jump
directly to this record.

Can anyone tell me how I can do this??



Nov 12 '05 #5
Whoops!!
Humble Pie
Phil
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
1. FindRecord cannot notify you whether it succeeded or not.

2. Before it can move, Access must save the current record. We have found
that doing that explicity avoids a range of issues.

3. What did you expect your code to do if the user updates FindIt to a blank (e.g. entering something and backspacing it out)?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Phil Stanton" <di********@stantonfamily.co.uk> wrote in message
news:40***********************@mercury.nildram.net ...
That looks a bit complicated Allen, why not a simple unbound combo box
called "FindIt" with the rowsource something like
SELECT RecNo FROM MyTable ORDER BY RecNo
and the AfterUpdate event as

Private Sub FindIt_AfterUpdate()

DoCmd.GoToControl "RecNo"
DoCmd.FindRecord FindIt

End Sub

Phil

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
Assuming that RecNo is a Number type field (not Text), put text box on

your
form and give it these properties:
ControlSource {leave this blank!}
Format General Number
Name txtFindRecNo
After Update [Event Procedure]

Then click the Build button (...) beside After Update.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, enter this:

Dim strWhere As String
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record."
Else
strWhere = "[RecNo] = " & Nz(Me.RecNo, 0)
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.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter" <pi*************@hotmail.com> wrote in message
news:b8**************************@posting.google.c om...
> I have a form with a field "RecNo". In stead if using "Ctrl F" and
> type a number I would like to use a seperate field on the form where
> you just type in the number and push enter. You should then jump
> directly to this record.
>
> Can anyone tell me how I can do this??



Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.