By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,482 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,482 IT Pros & Developers. It's quick & easy.

pulling only 1 record from BE

P: 26
Hi,
I am fairly new to access.
I would like to click a customer name in a textbox in my main form and have a pop up form that shows details of that customer. Everywhere I look (Northwind too), it seems that a simple where condition (eg customerID) will do the job.
BUT..
that means that all of the customers in the table will be pulled in the pop up form recordset but only 1 shown.
So if I have 5000 customers and want to change the phone number of 1, access pulls everything and shows 1?

So, is the only way to actually load 1 customer to write a criteria in the query itself? I don't want the user to be able to navigate through the recordset in the popup form so I don't see the point of loading everything.

Thanks
Mar 22 '17 #1

✓ answered by jforbes

When supplying the WhereCondition for DoCmd.OpenForm, it will limit the Record Source in the Form to only those records that satisfy the Where Condition.

So, if you have a Customer Table with a Primary Key of CustomerID and a Form called frmCustomer, if you were to open frmCustomer with the following:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmCustomer", , , "CustomerID=12"
only one record will be loaded into the Form.

Share this Question
Share on Google+
3 Replies


jforbes
Expert 100+
P: 1,107
When supplying the WhereCondition for DoCmd.OpenForm, it will limit the Record Source in the Form to only those records that satisfy the Where Condition.

So, if you have a Customer Table with a Primary Key of CustomerID and a Form called frmCustomer, if you were to open frmCustomer with the following:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmCustomer", , , "CustomerID=12"
only one record will be loaded into the Form.
Mar 22 '17 #2

P: 26
that's what I thought. But I have
DoCmd.OpenForm "frmPartyBook", acNormal, , Me!PartyID, acFormEdit, acDialog, "Change Booking ID "

if I debug.print the recorset of my pop up form I can see that all records are there but 1 shown (filtered). Why?
Mar 22 '17 #3

P: 26
I got iwrong here..
DoCmd.OpenForm "frmPartyBook", acNormal, , Me!PartyID, acFormEdit, acDialog, "Change Booking ID "


should be
DoCmd.OpenForm "frmPartyBook", acNormal, , "PartyID=" & Me!PartyID, acFormEdit, acDialog, "Change Booking ID "
Thanks
Mar 23 '17 #4

Post your reply

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