473,800 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Parameters with Autonumber

imrosie
222 New Member
Hello All,

(newbie)...I'm working on an Ordering app using the typical tables (customers, orders). I have a Search form to find existing customers prior to entering a new order. On the search form there's a combo control called 'custname' so that when a customer is located, the existing customer name is filled in and the account number goes into the Account control (from an autonumber field called CustomerID from Customer table). The rest of the data for street, city, etc go into the associated controls. So far no prob, I can click the cmd button (to begin new order), open the 'Order' form and pass the control data just fine, to the Order form.

On 'Search' form there's a 'NotInList' event with the 'custname' control, it opens another form called [Add or Delete Customer] by a double-click event. No problem there because on the the AutoNumber gets assigned to a new customer name and the rest of the data associated with the customer get stored appropriately.

On the Search form the problem comes in when I click the 'Edit Customer' cmd button to change information on an existing customer after a customer is located. the 'Edit Customer' button also opens the [Add or Delete Customer] form and passs the controls data. But something really wierd happens..... The CustomerID Account number passes into Customer Name control (on [Add or Delete Customer] form and the the account number (which is bound to CustomerID Autonumber) complains about duplicates. I suspect because the control is bound to CustomerID, which was fine when adding a new customer, but not for editing.

I have an 'AfterUpdate' event (recordset) associated as well with 'custname' but I don't think it's the problem.

I've been trying to figure this out for days and can't get it worked out. If anyone has encountered this before, please offer some suggestions,,,, ,thanks in advance,,,,,,I' m over my head. Here's the code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub custname_DblClick(Cancel As Integer)
  2. Me.[custname] = ""
  3. DoCmd.OpenForm "Add or Delete Customer"
  4. End Sub
  5.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub custname_NotInList(NewData As String, Response As Integer)
  2. MsgBox "The Name you entered is not found" & _
  3. vbCrLf & "Double Click to add a new customer", _
  4. vbInformation, "The name is not found"
  5. Response = DataErrCont
  6. End Sub
  7.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub custname_AfterUpdate()
  2. Dim rst As Object
  3.  
  4. Set rst = Me.RecordsetClone
  5.  
  6. rst.FindFirst "Customers.[CustomerID]=" & Me![custname]
  7. If Not rst.NoMatch Then
  8.  
  9.   Me.Bookmark = rst.Bookmark
  10. Else
  11.   'Not found!
  12. End If
  13.  
  14. End Sub
  15.  
This is code used for the 'Edit Customer' button
Expand|Select|Wrap|Line Numbers
  1. Private Sub createcust_Click()
  2. DoCmd.OpenForm "Add or Delete Customer"
  3. 'The event to open the Order form with some controls filled in
  4. Forms![Add or Delete Customer]![fullcustomer].Value = Forms![Search a Customer]![custname]
  5. Forms![Add or Delete Customer]![companies].Value = Forms![Search a Customer]![compname]
  6. Forms![Add or Delete Customer]![BillingAddress].Value = Forms![Search a Customer]![abilladdress]
  7. Forms![Add or Delete Customer]![newstateorprov].Value = Forms![Search a Customer]![astateOrprovince]
  8. Forms![Add or Delete Customer]![City].Value = Forms![Search a Customer]![City]
  9. Forms![Add or Delete Customer]![Title].Value = Forms![Search a Customer]![thetitle]
  10. Forms![Add or Delete Customer]![thezippostal].Value = Forms![Search a Customer]![ZIPCode]
  11. Forms![Add or Delete Customer]![acountry].Value = Forms![Search a Customer]![acountry]
  12. DoCmd.Close acForm, "Search a Customer", acSaveNo
  13. End Sub
  14.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub BeginOrder_Click()
  2. DoCmd.OpenForm "Add an Order and Details"
  3. 'The event to open the Order form with some controls filled in
  4. Forms![Add an Order and Details]![thefullname].Value = Forms![Search a Customer]![FullName]
  5. Forms![Add an Order and Details]![TheCompany].Value = Forms![Search a Customer]![compname]
  6. Forms![Add an Order and Details]![custacct].Value = Forms![Search a Customer]![custaccts]
  7. Forms![Add an Order and Details]![ShipAddress].Value = Forms![Search a Customer]![ShipAddress]
  8. Forms![Add an Order and Details]![thecountry].Value = Forms![Search a Customer]![acountry]
  9. Forms![Add an Order and Details]![ShipCity].Value = Forms![Search a Customer]![ShipCity]
  10. Forms![Add an Order and Details]![BillingAddress].Value = Forms![Search a Customer]![BillingAddress]
  11. Forms![Add an Order and Details]![ShipStateOrProvince].Value = Forms![Search a Customer]![ShipStateOrProvince]
  12. Forms![Add an Order and Details]![ShipZIPCode].Value = Forms![Search a Customer]![ShipZIPCode]
  13. DoCmd.Close acForm, "Search a Customer", acSaveNo
  14. End Sub
  15.  
So sorry to bombard with information ,but I thought it might clarify what's going on. thanks.

Rosie,,,,,,I've got to get some sleep..thanks
Jul 9 '07 #1
4 2356
MMcCarthy
14,534 Recognized Expert Moderator MVP
What is the record source of the "Add or Delete Customer" form?
Jul 17 '07 #2
imrosie
222 New Member
What is the record source of the "Add or Delete Customer" form?
Hi Mccarthy,

The record source is 'qrySearchCusto mer' based off of the Customers table, which has all the fields required. thanks.

Rosie
Jul 19 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub createcust_Click()
  2. 'createcust is not a great name as this is for editing a customer already in existance
  3. Dim stDocName As String
  4. Dim stLinkCriteria As String
  5.  
  6.     stDocName = "Add or Delete Customer"
  7.     stLinkCriteria = "[CustomerID] = " &  Me.custname
  8.     ' This will only work if the CustomerID is the bound control on the custname combobox
  9.     DoCmd.Open Form stDocName, , , stLinkCriteria
  10.  
  11. End Sub
  12.  
Jul 19 '07 #4
imrosie
222 New Member
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub createcust_Click()
  2. 'createcust is not a great name as this is for editing a customer already in existance
  3. Dim stDocName As String
  4. Dim stLinkCriteria As String
  5.  
  6.     stDocName = "Add or Delete Customer"
  7.     stLinkCriteria = "[CustomerID] = " &  Me.custname
  8.     ' This will only work if the CustomerID is the bound control on the custname combobox
  9.     DoCmd.Open Form stDocName, , , stLinkCriteria
  10.  
  11. End Sub
  12.  
Thanks so much....it worked beautifully. take care
Rosie
Jul 19 '07 #5

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

Similar topics

2
17359
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures (update, append) should be activated in order to transfer data to other tables. I tried to avoid any coding in VB, as I am not a professional, but I have found a statement in an article, that, unlike select queries, form's Input Property can't be...
3
14956
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
12
2810
by: Joel | last post by:
Hi all, Forgive me if I've expressed the subject line ill. What I'm trying to do is to call a c++ function given the following: a. A function name. This would be used to fetch a list of function descriptors for the overloaded functions of that name. A function descriptor would contain the address of the function to be called, and a description of the parameters that it must take. b. A list of parameters. This would be compared to the...
7
2872
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
39
7683
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down indicate: a) That I don't know enough b) Passing arguments by ref is bad
17
3606
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int (*fcmp)() = &cmp_fcn; qsort(..., fcmp); then everything works. But if instead I code qsort as:
1
8047
by: Punker | last post by:
Hi guys, I am trying to create export specifications for one of my queries. Now when I run the query on its own, it works perfectly. However when I try to export the data I get back the error message "Too few parameters. Expected 1." Has anyone encountered this before? Below is my SQL statement in case it helps: SELECT ClaimDetail.cd_ClaimId, BatchMaster.bm_BatchId, ClaimDetail.cd_BatchId, ClaimDetail.cd_ClaimNum,...
5
7740
by: Swinky | last post by:
I have a form "AccountInfo" that contains company names. I have inserted a subform "Contacts" with contact names and have established parent/child relationships between the two forms. All works well. I created an "Add New Contact" command button which passes the CompanyID (unique key set to autonumber) to the new record. This successfully works if the parent record (AccountInfo) has at least one existing contact. But if there are no...
2
1954
by: csmith8933 | last post by:
How do I write a function where the number of parameters it takes varies? This is what I have but it doesnt work. // function prototype void functionThree(int num1=1, int num2=2, int num3=3); int main() {
0
10287
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 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...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10042
tracyyun
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...
0
9099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6826
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();...
0
5479
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...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
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
2
3770
muto222
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.