473,385 Members | 1,523 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,385 software developers and data experts.

Data Selection and going to related record

Hi,
I am not that proficient in VBA but need to complete this small database.
I am creating a form to search the individual info
I need to have a text box to enter the last name with auto fill once you enter one or two letters.
Then I need all those records showed under that/those letters to show up in the list box.
Then by double clicking any of the record from the list box we shoud be able to go to that specific record from the other form.
At the bottom a button with name Select need to do the same operation as double clicking from list box.
I really appreciate your help in this regard.
Thanks,
Syed
Jan 10 '08 #1
8 1847
zaidlig
45
Can suggest an auto correcting combo box instead of a list box. First add the combo box (mine is Combo60) to your form define the rowsource as the list of items you want to choose from (you can use a query, table just about anything) make sure "limit to list" is yes. Leave control source blank. Now you have a self correcting way of getting to your record - as you type it will bring up matching items and if you pull down it will show all the items close to your typing.

Next add the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo60_AfterUpdate()
  2. 'Find the record that matches the control.
  3.     Me.RecordsetClone.FindFirst "[Standard] = '" & Me![Combo60] & "'"
  4.     Me.Bookmark = Me.RecordsetClone.Bookmark
  5. End Sub
Where [Standard] is the column name of the forms Record Source and Me![Combo60] is the selected value of the combo box. The cool thing is if you base the rowsource on a select unique query the combo box will always be a pull down of the records in the table you are trying to search and you don't need a separate row source table for your pull down.
Jan 10 '08 #2
I really appreciate your answer...
somehow its not working and not taking me to the related record of the table/form.
Would you please help me little further by adding more steps to get the job done.
(I am using Access 2000/2002)
I got the combo60 with the desired rows. I need either to select the name from that combo pull down list by double clicking it or pressing ENTER or by selecting a SELECT command button at the bottom.
The name of the form to show the related record is "frmCcondensed".
I am confused how that selection will take me to that specific record in the form.
With the wizard help, it takes me to the start of the form not to that specific record.
I might be asking little too much but your help will save me by all means.
Thanks and regards,
Syed
Jan 11 '08 #3
zaidlig
45
I really appreciate your answer...
somehow its not working and not taking me to the related record of the table/form.
Would you please help me little further by adding more steps to get the job done.
I got the combo60 with the desired rows. I need either to select the name from that combo pull down list by double clicking it or pressing ENTER or by selecting a SELECT command button at the bottom.
The name of the form to show the related record is "frmCcondensed".
I am confused how that selection will take me to that specific record in the form.
With the wizard help, it takes me to the start of the form not to that specific record.
I might be asking little too much but your help will save me by all means.
Thanks and regards,
Syed
Ok in my Example Combo60 is a control on the frmCcondensed. If you add the Combo60 to your frmCcondensed it will move the form to the selected record.

If you want form A to open form B based on the selected value of Combo60 then add Combo60 to form A and use this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo60_AfterUpdate()
  2. DoCmd.OpenForm "form name B", acNormal, , "[record ID]= '" & Me![Combo60] & "'", acFormEdit, acWindowNormal
  3. End Sub
Where [record ID] is the field name of the unique ID in the datasource of form B.
Jan 11 '08 #4
Again thanks,
now I am getting runtime error 2501 with message OpenForm action was canceled when I use intContactID in the code.
I am giving here all the steps I am taking:
I am creating a form with a combo box (named as combo60) and using intContactID, strLName, strFName from tblContact as row source (selecting hiding the first key column- intContactID in the wizard as recommended).
Then I am adding the code given by you:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo60_AfterUpdate()
  2. DoCmd.OpenForm "frmCcondensed", acNormal, , "[intContactID]= '" & Me![Combo60] & "'", acFormEdit, acWindowNormal
  3.  
  4. End Sub
If I use strLName in the code instead of intContactID then it takes me to the empty boxes of frmCcondensed without any option otherthan filling the info in
instead of getting to the desired result selected form combo box.

I hope this will help you to figure out how to help me :)
Thanks a lot,
Syed
Jan 11 '08 #5
Minion
108 Expert 100+
Try this code I think you'll find it works for you with a little tweaking.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbLastName_AfterUpdate()
  2.     DoCmd.OpenForm "<<target form name>>", , , "<<field name>> = '" & Me.cmbLastName & "'"
  3. End Sub
  4.  
<<target form name>> - thsi will be your target form
<<field name>> - this is your field name. This should be buffered by quotes without brackets.

So putting it all together if the form is called formTwo and the table field is called LastName. Then the code would look something like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbLastName_AfterUpdate()
  2.      DoCmd.Openform "formTwo", , , "LastName = '" & me.cmbLastName & "'"
  3. End Sub
  4.  
Hope this helps.

- Minion -
Jan 11 '08 #6
zaidlig
45
Again thanks,
now I am getting runtime error 2501 with message OpenForm action was canceled when I use intContactID in the code.
I am giving here all the steps I am taking:
I am creating a form with a combo box (named as combo60) and using intContactID, strLName, strFName from tblContact as row source (selecting hiding the first key column- intContactID in the wizard as recommended).
Then I am adding the code given by you:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo60_AfterUpdate()
  2. DoCmd.OpenForm "frmCcondensed", acNormal, , "[intContactID]= '" & Me![Combo60] & "'", acFormEdit, acWindowNormal
  3.  
  4. End Sub
If I use strLName in the code instead of intContactID then it takes me to the empty boxes of frmCcondensed without any option otherthan filling the info in
instead of getting to the desired result selected form combo box.

I hope this will help you to figure out how to help me :)
Thanks a lot,
Syed
Verify that the Combo60 is bound to column 1 it appears that its bound to column 2.

The row source data must be in the order you indicated "intContactID, strLName, strFName" with the widths being 0;#;# where # is any number and bound to column 1.

Next verify the form you are opening will open normally outside of the use off Combo60. Finally change your code to:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmCcondensed", acNormal, , "[intContactID]= '" & Me![Combo60] & "'"
Remember "[intContactID]" must a field name in the datasource of the form you are opening.
Jan 11 '08 #7
Thanks a lot Zaidlig, (and also thanks to Minion for your kind reply)
Its working fine now with the only note that before it was bound to 1 and when I changed it to bound 2 and changed strLName in the code instead of intContactID it started working instantly.
I really appreciate your kind help.
Syed
Jan 11 '08 #8
Hi,
Now to the next level of the problem...
I need to search a person by Last Name, City, Riding.
I 'll be using toggle box for these three boxes on the top
but from there on I am blank and need same kind help as I got before.
With two possible scenrios
1) All three search have the source- same single table
2) These three searches have different sources i.e depending on different tables/forms/queries.
Please accept my applology if I am asking too much.
Help will be highly appreciated.
Thnaks,
Syed
Jan 11 '08 #9

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

Similar topics

1
by: Deborah V. Gardner | last post by:
I have a form with a data source consisting of two linked tables, tblComplaints and tblViolations. When I click on a checkbox to add a violation related to the Complaint, I have used the AddNew...
8
by: Raven | last post by:
Hello, I get a error message when I try to Add data in a relational Access Database. This is the error message: "You cannot add or change a record because a related record is required in...
1
by: ccr | last post by:
Please view in a text editor so that the columnar text lines up. I used Terminal 9pt font to compose this post and copied/pasted to my newsreader program. I am writing in the hope that one of...
8
by: J. Black | last post by:
Hello everyone - I've been developing an incident tracking and reporting system for an emergency services outfit that I work with part time. It's going well, except for one fly in the ointment....
5
by: Jonny | last post by:
Hello, I have created a button on my form which when pressed does the following : 1) Run a pre-defined Macro, which is picking up a query and running my data to excel. However, I need the...
5
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework...
2
by: Bob | last post by:
I got three related datagrid views one parent and two children of the same. The two child tables contain many thousands of records and some of the contents are bitmap files in a sql server...
0
by: spowel4 | last post by:
VB 2005: Using an xml file as the data source, I need to fill a listbox with data based upon what was selected in a combobox. In other words, my data consists of a list of customers in a...
4
by: Neil | last post by:
Is there a problem with stability when one uses too many text (memo) fields? I'm having a problem with data from one record occasionally ending up in another record, though apparently not through...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.