473,473 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Explain vba search code

173 New Member
I managed to find a search example on the forum but i dont understand the following code properly........

can someone explain this to me:

Expand|Select|Wrap|Line Numbers
  1. Private Sub QuickSearch_AfterUpdate()
  2.  
  3. DoCmd.Requery
  4. Me.RecordsetClone.FindFirst "[provider] = '" & Me![QuickSearch] & "'"
  5. If Not Me.RecordsetClone.NoMatch Then
  6.    Me.Bookmark = Me.RecordsetClone.Bookmark
  7. Else
  8.    MsgBox "Could not locate [" & Me![QuickSearch] & "]"
  9. End If
  10.  
  11. End Sub
thanks
Dec 18 '06 #1
8 9154
missinglinq
3,532 Recognized Expert Specialist
Private Sub QuickSearch_AfterUpdate()
'Reruns the query the form is based on
DoCmd.Requery
'Goes to a record where the field provider is the same as the value in the control QuickSearch
Me.RecordsetClone.FindFirst "[provider] = '" & Me![QuickSearch] & "'"
'If a match is found a bookmark is set to the record
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
'If no match is found a messagebox popsup to report the failure
Else
MsgBox "Could not locate [" & Me![QuickSearch] & "]"
End If

End Sub

If a match is found, the bookmark will cause the appropriate record to be displayed.
Dec 18 '06 #2
Beany
173 New Member
thanks for that...........

what are the errors that you can get when you use this code?

im using this code for my search form but im having problems with the following line:
Expand|Select|Wrap|Line Numbers
  1. Me.RecordsetClone.FindFirst "[provider] = '" & Me![QuickSearch] & "'"
why do u think that is?
Dec 18 '06 #3
missinglinq
3,532 Recognized Expert Specialist
What problems/error codes are you getting? Is the field you're searching on named provider? Is the text box you're entering your search string in named QuickSearch! Otherwise, the code won't work!
Dec 19 '06 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
thanks for that...........

what are the errors that you can get when you use this code?

im using this code for my search form but im having problems with the following line:
Expand|Select|Wrap|Line Numbers
  1. Me.RecordsetClone.FindFirst "[provider] = '" & Me![QuickSearch] & "'"
why do u think that is?
Me.RecordsetClone gets all records currently bound to a form and puts them in a recordset. If your search form is not bound to a table or query it won't return anything.

Mary
Dec 19 '06 #5
Beany
173 New Member
Me.RecordsetClone gets all records currently bound to a form and puts them in a recordset. If your search form is not bound to a table or query it won't return anything.

Mary

Ok,
the error that i am getting is the following:

Run-time error '7951';

You entered an expression that has an invalid reference to the RecordsetClone property.


and it takes me to the code part which i mentioned in my previous post.

y is that?
Dec 19 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Ok,
the error that i am getting is the following:

Run-time error '7951';

You entered an expression that has an invalid reference to the RecordsetClone property.


and it takes me to the code part which i mentioned in my previous post.

y is that?
Is your form bound to a table or query?
Dec 19 '06 #7
Beany
173 New Member
Is your form bound to a table or query?
Its bound to a query qry_all_details.

what i have is a textbox that has another text box underneath it....

in the first text box i enter the providers name and it lists all the details in the second text box (in order of the provider - just showing the provider i searched for)

if i dont type in anything in the first textbox..... it just shows a list of all details in the second textbox(from qry_all_details)..........

what i want to do also is, by selecting the provider in the second textbox, i want it to bring up all the details in a form style on the same page(possibly below the two textboxes)....... how do i do it???

but firstly how do i rectify the error im getting?
Dec 19 '06 #8
NeoPa
32,556 Recognized Expert Moderator MVP
Try
Expand|Select|Wrap|Line Numbers
  1. Debug.Print "[provider] = '" & Me![QuickSearch] & "'"
before your line that searches for it and post the results (Copy from immediate pane - Ctrl-G to get there).
Dec 19 '06 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: davout | last post by:
Can anybody point me at some web resources that explain why Python is better than Perl, TCL, Ruby etc?
3
by: Bruce Pullen | last post by:
DB2 UDB 7.2 on AIX5.2 I'm running (VISUAL) EXPLAIN from DB2 Control Center on various SQL statements, but am restricted to using unrealistically small data volumes. I've heard that it is...
2
by: makthar | last post by:
Thanks for taking the time to read this note Can anyone explain what went wrong and any ideas how to fix it I have a search page With three buttons few drop downs and a textbox. The search...
3
by: Yuri | last post by:
Does anybody have a tool to store/retrieve explained sql? We're running DB2 8.2 on AIX. We would like to be able to compare old saved explains to the current ones and see if anything changed....
4
by: moondaddy | last post by:
I'm learning c# and see a code example where a value of null is assigned to a variable: int? a = null; I could not find this in the docs. can someone please explain exactly what the '?' is?...
4
by: Bruno Alexandre | last post by:
Hi guys, I'm using the asp:menu component and everything worked great in my machine, but when I upload the files to our Hosting I got this: http://portal.filterqueen.dk/portal2.fq/test.aspx ...
8
by: John Austin | last post by:
I need to understand why if I add a control and use AddHandler to connect its click event, it will work in Page_Load, but not in a Button_Click. The idea is that the user types some data, presses...
7
by: RobG | last post by:
Can someone explain to me why Firefox barfs on background and border in the following CSS and doesn't display the site the same as IE: #nav, #nav ul { background: <iw_value...
1
by: okonita | last post by:
I need major help resolving a UDF error. My environment id DB2 UDBv8.2 and v9.1 on a Linux and Windows server. I am getting a SQL20148N error which states as follows: SQL20148N Routine...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
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.