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. - Private Sub LastName_NotInList(NewData As String, Response As Integer)
-
Dim result
-
Dim msg As String
-
Dim cr As String
-
cr = Chr$(13)
-
If NewData = "" Then Exit Sub
-
msg = "'" & NewData & "' is not in the list." & cr & cr
-
msg = msg & "Do you want to add it?"
-
If MsgBox(msg, vbQuestion + vbYesNo) = vbYes Then
-
DoCmd.OpenForm "Add an Order and Details", , , , acAdd, acDialog, NewData
-
End If
-
result = DLookup("[LastName]= " & Chr(34) & NewData & Chr(34))
-
If IsNull(result) Then
-
Response = acDataErrContinue
-
MsgBox "Please try again!"
-
Else
-
Response = acDataErrAdded
-
End If
-
-
End Sub
-
-
Public Sub Acct_Name_Not_Found(NewData)
-
Dim ans As Variant
-
' new acct
-
gbl_exit_name = False
-
-
ans = MsgBox("Would you like to add record for this customer?", _
-
vbYesNo, "Add New acct?")
-
-
If ans = vbNo Then
-
Me.Customer_ID = Null
-
DoCmd.GoToControl "CustomerID"
-
GoTo exit_it
-
End If
-
-
' add acct
-
DoCmd.OpenForm ("Add Customer Record")
-
Form_Add_Customer_Record.CustomerID = NewData
-
-
Me.CompanyName = Null
-
DoCmd.GoToControl "CustomerID"
-
-
exit_it:
-
-
End Sub
Please help....thanks
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.
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
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.
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.
Rabbit 12,516
Recognized Expert Moderator MVP
The help files have great examples to help you along.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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 ...
| |