473,466 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to open 2nd form with 'copied' data from 1st form

imrosie
222 New Member
Hello any expert out there. I'm yet another newbie (yan) who needs lots of help. Here's my issue. I'm trying to create an product ordering database.

I set up a 'Search' form with the ability to search existing customers (and autopop info) into the appropriate fields(ie, name, address, firstname, lastname, etc.)which works so far. However if I don't locate an existing customer and need to add a 'new one I believe I should use the 'NotInListEvent. I'm trying to figure this one out, but need help on the best way to do this.

Once I've get past the 'NotInList' event and get a 'new account' stored into the DB....the next thing is to figure out is how to open the actual ordering form (called Add An Order and Details)on a click or double click) and have it contain the new or 'searched' name (plus other fields; address, firstname, lastname, etc.) already populated from the previous form called 'Search' In

I found forum instructions close to what I want for this, but so far I can't get it working. In my 'Search form' I have a field 'CustomerID' autonum assigned if there is no existing customer number. I have a 'FirstName' and 'LastName' field. I want to have the 'NotInList' attached to the LastName field



Here is the code I can't get working. Please anyone take a look and help if you can. thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. Private Sub LastName_NotInList(NewData As String, Response As Integer)
  2. Dim result
  3. Dim msg As String
  4. Dim cr As String
  5. cr = Chr$(13)
  6. If NewData = "" Then Exit Sub
  7. msg = "'" & NewData & "' is not in the list." & cr & cr
  8. msg = msg & "Do you want to add it?"
  9. If MsgBox(msg, vbQuestion + vbYesNo) = vbYes Then
  10. DoCmd.OpenForm "Add an Order and Details", , , , acAdd, acDialog, NewData
  11. End If
  12. result = DLookup("[LastName]= " & Chr(34) & NewData & Chr(34))
  13. If IsNull(result) Then
  14. Response = acDataErrContinue
  15. MsgBox "Please try again!"
  16. Else
  17. Response = acDataErrAdded
  18. End If
  19.  
  20. End Sub
  21.  
  22. Public Sub Acct_Name_Not_Found(NewData)
  23. Dim ans As Variant
  24. ' new acct
  25. gbl_exit_name = False
  26.  
  27. ans = MsgBox("Would you like to add record for this customer?", _
  28. vbYesNo, "Add New acct?")
  29.  
  30. If ans = vbNo Then
  31. Me.Customer_ID = Null
  32. DoCmd.GoToControl "CustomerID"
  33. GoTo exit_it
  34. End If
  35.  
  36. ' add acct
  37. DoCmd.OpenForm ("Add Customer Record")
  38. Form_Add_Customer_Record.CustomerID = NewData
  39.  
  40. Me.CompanyName = Null
  41. DoCmd.GoToControl "CustomerID"
  42.  
  43. exit_it:
  44.  
  45. End Sub

Please help....thanks
May 2 '07 #1
5 1880
Rabbit
12,516 Recognized Expert Moderator MVP
Well, after you pass the newdata in the openargs to the form, in the form load you would use that to look up the information and populate the fields.
May 4 '07 #2
imrosie
222 New Member
Well, after you pass the newdata in the openargs to the form, in the form load you would use that to look up the information and populate the fields.
Sorry, I've been out ill....thanks for your quick response.
How would I re code to retain the information in the second form? thanks
May 8 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Sorry, I've been out ill....thanks for your quick response.
How would I re code to retain the information in the second form? thanks
Well, you passed the NewData which is the last name. I assume that last name is unique in which case in the second form, you would dlookup the values and populate the fields.
May 8 '07 #4
imrosie
222 New Member
Well, you passed the NewData which is the last name. I assume that last name is unique in which case in the second form, you would dlookup the values and populate the fields.
I will try the Dlookup and see what happens. If you got a snippet of what that should look like, could you paste it in? thanks so much for your help.
May 9 '07 #5
Rabbit
12,516 Recognized Expert Moderator MVP
The help files have great examples to help you along.
May 10 '07 #6

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

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
2
by: Rocky A | last post by:
This is my first posting so please be gentle I've been writing access programs for only about a year and may have bit off more than I can chew but....... I've written an operations program for...
4
by: sparks | last post by:
We have a database that reads in and formats raw data. We were using queries to format the data per person and outputing reports. The other database has the persons personal information. I changed...
1
by: celtic_kiwi | last post by:
I have an Access 97 database, quite large, and have started getting the error, Error 3048: Can't Open any more databases. -The data is split from the application (front end and back end). -The...
2
by: celtic_kiwi | last post by:
I have an Access 97 database, quite large, and have started getting the error, Error 3048: Can't Open any more databases. -The data is split from the application (front end and back end). -The...
6
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when...
4
JodiPhillips
by: JodiPhillips | last post by:
MS Access2000 Hi everyone, I've searched the forums for an answer to this question and nothing jumps out at me. When a database is opened I want to automatically run code (at start-up) that...
2
by: troy_lee | last post by:
Let's say I have a template form named Form1. I have two text fields named Month and Year. Using an event procedure from another form, I want to: 1) Open the template form 2) Name the form...
4
by: omono84 | last post by:
I know that this should be rather simple but i seem to be missing a step to get it to work. and have been unable to find a solution on the net. The aim is that I click on the open button to find...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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...
0
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,...
0
isladogs
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...
0
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...
0
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 ...

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.