I have a database developed in MS Access 2000 that allows people to enter training histories for staff. The staff information is stored in tblStaff, and the training histories are stored in tblTraining. The main form (frmDataEntry) contains the staff contact information and a continuous subform displaying the selected staff's training history.
The desire was for the ability to allow the data entry person to search the database by staff's last name. To do this I placed an unbound text box and a command button in frmDataEntry that opens a second form (frmSrchResults ). The second form contains a list box whose row source is a query of tblStaff with the criteria being "Like ([Forms]![frmDataEntry]![txtLNameSrch] & "*")", which displays all the possible matches in the list box on frmSrchResults. The data entry person can either double click on the correct person or highlight the correct person and select a command button that populates frmDataEntry with the selected person.
The original coding I used is as follows: - Private Sub cmdMatch_Click()
-
-
DoCmd.OpenForm "DataEntry frm", acNormal
-
DoCmd.ShowAllRecords
-
DoCmd.FindRecord Forms![frmSrchResults]![txtNameSrchResults].Column(0)
-
-
-
DoCmd.Close acForm, "frmSrchResults"
-
[Forms]![frmDataEntry![txtLNameSrch] = ""
-
-
End Sub
The above code worked originally when first developed. However, I know receive a runtime error 2162 - A macro set to one of the current field's properties failed because of an error in a FindRecord action argument.
Can anyone help me rewrite this code so that it works? I have searched for code but am unable to find anything.
Thanks!
1 2784
I have a database developed in MS Access 2000 that allows people to enter training histories for staff. The staff information is stored in tblStaff, and the training histories are stored in tblTraining. The main form (frmDataEntry) contains the staff contact information and a continuous subform displaying the selected staff's training history.
The desire was for the ability to allow the data entry person to search the database by staff's last name. To do this I placed an unbound text box and a command button in frmDataEntry that opens a second form (frmSrchResults ). The second form contains a list box whose row source is a query of tblStaff with the criteria being "Like ([Forms]![frmDataEntry]![txtLNameSrch] & "*")", which displays all the possible matches in the list box on frmSrchResults. The data entry person can either double click on the correct person or highlight the correct person and select a command button that populates frmDataEntry with the selected person.
The original coding I used is as follows: - Private Sub cmdMatch_Click()
-
-
DoCmd.OpenForm "DataEntry frm", acNormal
-
DoCmd.ShowAllRecords
-
DoCmd.FindRecord Forms![frmSrchResults]![txtNameSrchResults].Column(0)
-
-
-
DoCmd.Close acForm, "frmSrchResults"
-
[Forms]![frmDataEntry![txtLNameSrch] = ""
-
-
End Sub
The above code worked originally when first developed. However, I know receive a runtime error 2162 - A macro set to one of the current field's properties failed because of an error in a FindRecord action argument.
Can anyone help me rewrite this code so that it works? I have searched for code but am unable to find anything.
Thanks!
I believe the FindRecord method requires focus on the control that will return the field you are searching on (in this case [txtNameSrchResu lts]) , so insert the following statement on the line before the FindRecord command is issued. -
Forms![frmSrchResults]![txtNameSrchResults].SetFocus
If that does not work, the link below is provided for use as a reference source.. http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
Also, although it is not required, you should name your listbox lstNameSrchResu lts instead of txtNameSrchResu lts to comply with recommended naming standards for Access objects. The prefix txt stands for textbox (not listbox) under the naming standards, and might confuse anyone looking at your code.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Glabbeek |
last post by:
I'm changing the layout of my site. Instead of using tables, I will use
DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not
the correct width. Mozilla and Opera are showing the page the way I
want. Does anybody know a solution for this?
First of all, the code I am using:
CSS
-------
body {
|
by: Alan Mackenzie |
last post by:
To all those who use (X)Emacs's CC Mode to edit C, C++, Java,
Objective-C, Pike, AWK or IDL:
To help direct the development of CC Mode, it would be useful to find out
how people use the auto-newline "minor mode" facility. If you could
spare a little time, would you answer these questions, please:
o Do you program with auto-newline switched on (e.g. do you get NLs
inserted automatically after typing a `;' or `{')?
o Did you configure...
|
by: Vijay Kumar R. Zanvar |
last post by:
Hello,
Unlike register, auto keyword can not be used to
declare formal parameter(s). Is there any specific
reason for this?
Kind regards,
Vijay Kumar R. Zanvar
|
by: VB Programmer |
last post by:
I created a page which I am using to prevent the user from hitting the BACK
button. I'll call it my "Auto Jump" page. When it is called it basically
auto-redirects to a page specified in the QueryString. (We'll call the page
it goes to the "destination page".) If the user hits BACK on the
destination page it should goto the "Auto Jump" page which should put you
right back to where you hit the button.
In Page_Load of this "Auto Jump"...
|
by: Brian |
last post by:
hello,
I am looking for a way to auto refresh a web page that I created, but
also let the user choose to stop the auto refresh. I can not figure out how
to stop the auto refresh. Any help would be appreciated.
Thanks,
Brian
| |
by: maya |
last post by:
at work they decided to center divs thus:
body {text-align:center}
#content {width: 612px; text-align:left; margin: 0 auto 0 auto; }
this works fine in IE & FF, EXCEPT in FF it doesn't work if I change
'auto' to 0 for left and right margin values; I have to leave those at
'auto'.. so I would like to know what exactly means 'auto' -- what
value it represents exactly (and does it apply for all elements/values
you might apply 'auto' to?)
|
by: S.Dickson |
last post by:
I had an access database that i use as an ordering system. I have a
form for entering customer details. When i add a new customer on the
form the customer number is an auto number that appears when i type in
the details.
I have just moved over to mysql server with access as the front end. I
have setup the sql tables with the customer number as autonumber.
When i go into the form and add a new customer it does not generate the
|
by: nospam_news |
last post by:
I currently get asked about my usage of "auto". What is it for?
The keyword is clearly superflous here.
In contrast to the huge majority of C/C++ developers I write
definitions very explicitly like that:
int main(char argc, char *argv, char *env) {
try {
auto Exception mainException(1);
mainException.setErrNo(42);
|
by: Piotr K |
last post by:
Hi,
I've encountered a strange problem with Firefox which I don't have any
idea how to resolve. To the point: I've <divelement with a style
"height: auto" and I want to retrieve this value ("auto") in
JavaScript - however instead of getting "auto" value, I get calculated
height. In IE and Opera it simply returns "auto".
Any ideas how to check in Firefox if element height was set to
"auto" ? I'll be grateful for any help.
|
by: JOYCE |
last post by:
Look the subject,that's my problem!
I hope someone can help me, thanks
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |