p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Microsoft Office > Access and Access VBA > Access
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 8th, 2009, 12:28 PM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2009
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use a form for both lookup and new data entry

I know this is a naive question, but my books just do not answer it.

I need to use a form for both new customer data entry and for customer lookup. (It is actually an order entry form). I see the property that I need to set to allow a form to do both. So first I make fields for first name and last name. Then is there an automatic way to have the user enter a name and have the form look up the name and if it does not exist, then use the name as a new customer?

At the least I would like to avoid making the user go through the whole search process with whole name, part name, etc. options. Would also like to avoid making the user go to the bottom of the form (which will involve a scroll) to press the button for a new record.

Is there a way to
1)have the user enter a last name and see a drop down of all first and last names in the db that match that last name, letting them click on the appropriate line if they see the customer they want, and
2) if the use determines that there is no match, then create a new record easily without needing to scroll?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old September 8th, 2009, 04:03 PM
Friend of Wrox
Points: 3,645, Level: 25
Points: 3,645, Level: 25 Points: 3,645, Level: 25 Points: 3,645, Level: 25
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,114
Thanks: 2
Thanked 4 Times in 4 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

If you want both data entry and look-up, you run into a problem. People may accidentally type over a record if you don't lock it first when they're searching. It's best to have a search field on the form for looking up data. Once found, an EDIT button would allow the user to change data by making the form read/write vs. read-only.

If you want to avoid that step, you can open a form for intended data entry at a new record. Populate a last name and first name dropdowns with all persons in the database. When users type into the last name dropdown, Access will try to autocomplete the name. When found, the person tabs to the first name field whereupon that dropdown will requery to be only those first names whose last names match what the person selected. Once done, if a record matches with that name combination, you can have the record jump to the one with that combination last/first name. If no records match, you'd be at a new record anyway and would be entering a new record.

Because last name / first name combination is not ideally unique (take "John Smith," for example), it's not the best approach for your desired situation. A better method would be for you to enter a UNIQUE identifier first (instead of name) and then the record would either jump to an existing one or become a new record. However, new customers will not have a unique ID yet.

Therefore, the best idea is to have that search field on top of the form with a subform that lists the finds. You can then highlight one and click an EDIT button, or find none and click a CREATE button.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division

Last edited by SerranoG : September 8th, 2009 at 04:49 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old September 13th, 2009, 03:42 PM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2009
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Making all controls match selection of combo box

In using the combo box, I ran into a problem I did not anticipate.

I want a use to select a customer on a form and have the form then reflect many fields for that record. Specifically, I want the user to use a combo box to select a customer (I show the last name and first name in the drop down of the combo box) for whom they can then perform other actions. The combo box itself seems to be fine as it displays the record selected in the drop down.

But I am doing something wrong. I have a form and the source of the data is the customer table. I have 3 dummy records with names as first & last, first2& last2, first3 & last3 as the entries for fname and lname fields. (I also have an address entered for the first record.)

I created a combo box using the wizard. I selected, in order:
Lookup values in table/query
Selected Customer table as the data source
Chose, in order, Lname and Fname fields
Chose Ascending for Lname and Ascending for Fname
Then finished.

In the form design view, this put a query into the row source field for the combo box that selected the CustID key field along with the Fname and Lname fields and left the control source property blank. (The control itself displays the last name at form view, which is what I prefer).

When I go to form view, the drop down works fine for this control. But none of the other fields in the form automatically switch to reflect the proper record. The form itself has its record source as the Customer table

I tried a number of things to force the issue, some didn't help, some caused the data in the underlying table to change.

Once I have the selection in the combo box, how do I make all the controls in the form automatically match the record which I just selected in the combo box?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old September 17th, 2009, 05:54 PM
Friend of Wrox
Points: 3,645, Level: 25
Points: 3,645, Level: 25 Points: 3,645, Level: 25 Points: 3,645, Level: 25
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,114
Thanks: 2
Thanked 4 Times in 4 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

The combobox's AfterUpdate event would have to make a recordset clone of the data. Next you'd use the FindFirst method to match based on the criterion. Then you'd bookmark the find and set the current form's recordsource's bookmark match the found clone's bookmark. If not found at all in the clone, then you'd start a new record.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
InfoPath form data entry to db Pearljam23 BOOK: Beginning InfoPath 2003 1 August 29th, 2008 03:38 AM
The best way to design a data entry web form cesemj ASP.NET 2.0 Basics 2 November 5th, 2007 02:44 PM
Data Entry Form in VB.Net 2002 SanLion WinFS 0 April 11th, 2007 03:01 AM
Need to dup a whole record in a data entry form markw707 Access 4 August 29th, 2005 11:09 AM
New Record Data entry one form lgpatterson Classic ASP Basics 1 February 8th, 2005 12:58 AM



All times are GMT -4. The time now is 05:24 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc