473,503 Members | 9,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3865
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
7207
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
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7294
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,...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.