Here's what I've got:
I've got a form with combo boxes. you can select already existing
company names or type in new ones. if you type in a new one, it
prompts you to double click the combo box if you want to add a new
company. when you double click it brings up the new company form so
you can enter the rest of the information besides just the name there.
This all works.
Here's what I want:
I want the new company that is typed in the first form (and causes the
double click prompt) to be copied into the new company form, so the
name doesn't have to be typed twice.
Form information:
First form is called 'Quote'
Combo Box I'm using is 'CompanyID'
Second form is 'Company'
Text Box that i want the info to go to is 'CompanyNickname'
I've tried using the Wherecondition in the docmd.openform but it
doesn't work.
Thanks in advance for the help and for posting the reply to the groups.
Here's the code:
Private Sub CompanyID_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub CompanyID_DblClick(Cancel As Integer)
On Error GoTo Err_CompanyID_DblClick
Dim lngCompanyID As Long
If IsNull(Me![CompanyID]) Then
Me![CompanyID].Text = ""
Else
lngCompanyID = Me![CompanyID]
Me![CompanyID] = Null
End If
DoCmd.OpenForm "Company", , , "[CompanyNickname] = ' & Me!CompanyID
& '", , acDialog, "GotoNew"
Me![CompanyID].Requery
If lngCompanyID <> 0 Then Me![CompanyID] = lngCompanyID
Exit_CompanyID_DblClick:
Exit Sub
Err_CompanyID_DblClick:
MsgBox Err.Description
Resume Exit_CompanyID_DblClick
End Sub 6 4146
Use OpenArgs on the Load event of your Company form:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![CompanyNameField] = Me.OpenArgs
Forms![Company]![Address].SetFocus
End If
End Sub
I also fire the OpenForm directly from the combo box on the On Not In
List event when the item typed does not match anything in the list:
Private Sub CoID_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 "Company", , , , acAdd, acDialog, NewData
End If
result = DLookup("[CompanyNameField]", "Company", "[CompanyNameField]=
" & Chr(34) & NewData & Chr(34))
If IsNull(result) Then
Response = acDataErrContinue
MsgBox "Please try again!"
Else
Response = acDataErrAdded
End If
End Sub
Supply your own field and form names. Good luck!!
Thanks so much. i thought i replied yesterday, but apparently i'm
don't know how to use google groups correctly. It works beautifully
and i quit using my old code entirely. i trimmed out several things.
i didn't know what the result= line was for, so i took it out, and i
took out everything below that because it was causing 'text is not in
the list' errors to come up even though it was going into the creation.
here's what i have left. Thanks again.
Quote Form:
Private Sub CompanyID_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 "Company", , , , acAdd, acDialog, NewData
End If
End Sub
----
Company Form:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![CompanyNickname] = Me.OpenArgs
Forms![quote]![CompanyID].SetFocus
End If
End Sub
------
Koontzie wrote: Use OpenArgs on the Load event of your Company form:
Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then Me![CompanyNameField] = Me.OpenArgs Forms![Company]![Address].SetFocus End If End Sub
I also fire the OpenForm directly from the combo box on the On Not In List event when the item typed does not match anything in the list:
Private Sub CoID_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 "Company", , , , acAdd, acDialog, NewData End If result = DLookup("[CompanyNameField]", "Company",
"[CompanyNameField]= " & Chr(34) & NewData & Chr(34)) If IsNull(result) Then Response = acDataErrContinue MsgBox "Please try again!" Else Response = acDataErrAdded End If End Sub
Supply your own field and form names. Good luck!!
problem. i have the data entry form and then i have a data edit form.
i get an error when i apply the same script to the data edit form.
Is there a way to change the code below so it knows what form it's
coming from and then run the appropriate line? Either
Forms![quote]![CompanyID].SetFocus or Forms![Quote
Edit]![CompanyID].SetFocus
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![CompanyNickname] = Me.OpenArgs
Forms![quote]![CompanyID].SetFocus
End If
End Sub
Thanks.
beowulfs wrote: Thanks so much. i thought i replied yesterday, but apparently i'm don't know how to use google groups correctly. It works beautifully and i quit using my old code entirely. i trimmed out several things. i didn't know what the result= line was for, so i took it out, and i took out everything below that because it was causing 'text is not in the list' errors to come up even though it was going into the
creation. here's what i have left. Thanks again.
Quote Form:
Private Sub CompanyID_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 "Company", , , , acAdd, acDialog, NewData End If
End Sub ---- Company Form:
Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then
Me![CompanyNickname] = Me.OpenArgs
Forms![quote]![CompanyID].SetFocus
End If End Sub
------ Koontzie wrote: Use OpenArgs on the Load event of your Company form:
Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then Me![CompanyNameField] = Me.OpenArgs Forms![Company]![Address].SetFocus End If End Sub
I also fire the OpenForm directly from the combo box on the On Not
In List event when the item typed does not match anything in the list:
Private Sub CoID_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 "Company", , , , acAdd, acDialog, NewData End If result = DLookup("[CompanyNameField]", "Company", "[CompanyNameField]= " & Chr(34) & NewData & Chr(34)) If IsNull(result) Then Response = acDataErrContinue MsgBox "Please try again!" Else Response = acDataErrAdded End If End Sub
Supply your own field and form names. Good luck!!
Private Sub Form_Load()
If IsNull(Me.OpenArgs) Then
Forms("Quote Edit").CompanyID.SetFocus
Else
Me.CompanyNickname = Me.OpenArgs
Forms("Quote").CompanyID.SetFocus
End If
End Sub
Darryl Kerkeslager
"beowulfs" <tr**@scheh.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... problem. i have the data entry form and then i have a data edit form. i get an error when i apply the same script to the data edit form.
Is there a way to change the code below so it knows what form it's coming from and then run the appropriate line? Either Forms![quote]![CompanyID].SetFocus or Forms![Quote Edit]![CompanyID].SetFocus
Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then
Me![CompanyNickname] = Me.OpenArgs
Forms![quote]![CompanyID].SetFocus
End If End Sub
Thanks.
Thanks for the code, but it doesn't work. it runs through first one
always. i need something that will determine which form is the
referrer. so like,
if form referrer is "Quote" then ' <-------don't know how to do this
If IsNull(Me.OpenArgs) Then
Forms("Quote").CompanyID.SetFocus
End If
Else If Form referrer is "Quote Edit" Then '<-------don't know how
to do this
If IsNull(Me.OpenArgs)Then
Forms("Quote Edit").CompanyID.SetFocus
End If
End If
Else
End If
I just don't know how to call up a form referrer property, if there
even is such a thing. Thanks again.
Darryl Kerkeslager wrote: Private Sub Form_Load() If IsNull(Me.OpenArgs) Then Forms("Quote Edit").CompanyID.SetFocus Else Me.CompanyNickname = Me.OpenArgs Forms("Quote").CompanyID.SetFocus End If End Sub
Darryl Kerkeslager
"beowulfs" <tr**@scheh.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... problem. i have the data entry form and then i have a data edit
form. i get an error when i apply the same script to the data edit form.
Is there a way to change the code below so it knows what form it's coming from and then run the appropriate line? Either Forms![quote]![CompanyID].SetFocus or Forms![Quote Edit]![CompanyID].SetFocus
Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then
Me![CompanyNickname] = Me.OpenArgs
Forms![quote]![CompanyID].SetFocus
End If End Sub
Thanks.
What my code assumed was that when you were opening the Form from Form
"QuoteEdit", that you would not use any OpenArgs, thus it would be Null
and this line would run: Forms("Quote Edit").CompanyID.SetFocus
Perhaps you need to test for Len(Me.OpenArgs)=0 instead of IsNull, but the
principle is the same.
Darryl Kerkeslager
"beowulfs" <tr**@scheh.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com... Thanks for the code, but it doesn't work. it runs through first one always. i need something that will determine which form is the referrer. so like, if form referrer is "Quote" then ' <-------don't know how to do this If IsNull(Me.OpenArgs) Then Forms("Quote").CompanyID.SetFocus End If Else If Form referrer is "Quote Edit" Then '<-------don't know how to do this If IsNull(Me.OpenArgs)Then Forms("Quote Edit").CompanyID.SetFocus End If End If Else End If
I just don't know how to call up a form referrer property, if there even is such a thing. Thanks again. Darryl Kerkeslager wrote: Private Sub Form_Load() If IsNull(Me.OpenArgs) Then Forms("Quote Edit").CompanyID.SetFocus Else Me.CompanyNickname = Me.OpenArgs Forms("Quote").CompanyID.SetFocus End If End Sub
Darryl Kerkeslager
"beowulfs" <tr**@scheh.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... problem. i have the data entry form and then i have a data edit form. i get an error when i apply the same script to the data edit form.
Is there a way to change the code below so it knows what form it's coming from and then run the appropriate line? Either Forms![quote]![CompanyID].SetFocus or Forms![Quote Edit]![CompanyID].SetFocus
Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then
Me![CompanyNickname] = Me.OpenArgs
Forms![quote]![CompanyID].SetFocus
End If End Sub
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Scott |
last post by:
Creating an application in Access with a number of "screens" which are just
forms linked together by command buttons (click button, opens new form,
closes old form).
Each form opens and...
|
by: Doug |
last post by:
I have a Do-Loop routine that checks the values of certain fields in a
Form (F_OmissionCheck) for omissions. If the field is blank, the
strOmissions variable is modified with additional verbiage...
|
by: aaaaaa |
last post by:
Hi,
I created some forms and during the wizard I chose the Datasheet View,
and when I open the forms from the main objects window they open up in
datasheet view. But when I created a switchboard...
|
by: David B |
last post by:
I have an app which handles data relating to cattle.
The ear tag number consists of 3 parts. Country code - UK. Farm Code - 107248.
and animal number - 600555.
At present the complete set has...
|
by: nic |
last post by:
Hi
I am currently having problems getting two forms to behave the way I
want. I have two tables Student and Application, and their respective
forms. (Tables)Student has StudentID (PK) & an...
|
by: jpr |
last post by:
Hello,
I need some help. I have a form named MASTER based on a table also
called MASTER.
A control of my form in names SSN which stores the client SSN.
On the same form I have placed a subform...
|
by: Parasyke |
last post by:
I have what is probably a simple fix for the gurus. I have one form
that has several products listed and I want to double-click onto the
field to bring up a more detailed product form of the chosen...
|
by: D Giles |
last post by:
Have found many solutions on this forum to get to this point so finally registered.
I have a form which should load 17 forms.
Private Sub Form_Load()
On Error GoTo Err_Form_Load
DoCmd.Minimize...
|
by: seraieis |
last post by:
Hi all,
I have an Access database with roughtly 70 different forms that I need to change the background image for. Now, short of opening all these forms individually, and changing the "Picture"...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |