Okay lets see if I can do this with out confusing myself or others. First I will give ALL the details then state my problem and request at the bottom. Tables: tblContacts
ID
Company
LastName
FirstName
Initial
E-MailAddress
JobTitle
BuisnessPhone
HomePhone
MobilePhone
faxNumber
Address
City
State/Province
Zip/PostalCode
UserName (PK)
ChargeCode (FK)
LocationCode (FK) tblAssets
ID (PK)
AssetNumber
SerialNumber
ComputerName
DeploymentDate
Active
UserName (FK)
OfficeName (FK)
OSName (FK)
ModelName (FK) tblModel
ModelID (PK)
ModelName tblOSVersion
OSName (PK) tblOfficeVersio n
OfficeID (PK)
OfficeName tblLocation
LocationCode (PK) tblChargeCode
ChargeCode (PK)
** Referential Integrity is Enforced on All tables** Query1 -
SELECT IIf(IsNull([LastName]),IIf(IsNull([FirstName]),[Company],[FirstName]),IIf(IsNull([FirstName]),[LastName],[LastName] & ", " & [FirstName])) AS [File As], IIf(IsNull([LastName]),IIf(IsNull([FirstName]),[Company],[FirstName]),IIf(IsNull([FirstName]),[LastName],[FirstName] & " " & [LastName])) AS [Contact Name], tblContacts.*
-
FROM tblContacts
-
ORDER BY IIf(IsNull([LastName]),IIf(IsNull([FirstName]),[Company],[FirstName]),IIf(IsNull([FirstName]),[LastName],[LastName] & ", " & [FirstName])), IIf(IsNull([LastName]),IIf(IsNull([FirstName]),[Company],[FirstName]),IIf(IsNull([FirstName]),[LastName],[FirstName] & " " & [LastName]));
-
Query5 -
SELECT tblContacts.LastName+' '+tblContacts.FirstName+', '+tblContacts.Initial AS Expr1, tblContacts.UserName, tblAssets.ComputerName, tblContacts.LocationCode, tblContacts.ChargeCode, tblAssets.AssetNumber, tblAssets.SerialNumber, tblContacts.[E-mailAddress], tblContacts.JobTitle, tblContacts.BusinessPhone, tblContacts.Address, tblContacts.City, tblContacts.[State/Province], tblContacts.[ZIP/Postal Code], tblOfficeVersion.OfficeName, tblAssets.OSName, tblModel.ModelName
-
FROM tblOfficeVersion INNER JOIN (tblModel INNER JOIN (tblContacts INNER JOIN tblAssets ON tblContacts.UserName = tblAssets.UserName) ON tblModel.ModelID = tblAssets.ModelName) ON tblOfficeVersion.OfficeID = tblAssets.OfficeName;
-
Forms (only listing three i am concerned with for question) frmSearchUsers
Record Source: Query1 Fields:
txtFileAs
txtContactName
txtID
txtCompany
txtLastName
txtFirstName
txtInitial
txtE-MailAddress
txtJobTitle
txtBuisnessPhon e
txtHomePhone
txtMobilePhone
txtfaxNumber
txtAddress
txtCity
txtState/Province
txtZip/PostalCode
txtUserName (PK)
txtChargeCode (FK)
txtLocationCode (FK) frmAssets
txtAssetNumber
txtSerialNumber
txtComputerName
txtDeploymentDa te
txtActive
txtUserName (FK)
txtOfficeName (FK)
txtOSName (FK)
txtModelName (FK) frmSystemPrepCh ecklist
Record Source: -
SELECT tblContacts.[LastName], tblContacts.[FirstName], tblContacts.[ChargeCode], tblContacts.[BusinessPhone], tblContacts.[UserName], tblAssets.[AssetNumber], tblAssets.[SerialNumber], tblAssets.[ModelName], tblAssets.[ComputerName] FROM tblContacts LEFT JOIN tblAssets ON tblContacts.UserName=tblAssets.[UserName];
-
Fields:
txtLastName
txtFirstName
txtUserId
txtComputerName
cboModelName
txtAssetNumber
txtSerialNumber
txtBuisnessPhon e
txtChargeCode
Okay so here si the deal. The user will open "frmAssets and will enter in new data to the fileds and save form and return to switchboard then will open "frmSearchU ser" and either search for current user or will enter new user infor by using cmdAddFromOutlo ok button. Then pick user they want to add and push okay then search for user in list and then the text boxes are popualted with user info. There is a button "cmdSystemPrepC hecklist", upon clicking this it will open the frmSystemPrepCh ecklist.
What happens is when the frmSystemPrepCh ecklist opens it automatically open to the first record, then you have to go down to the record selector at the bottom of the form and run a search for who you are looking for. What I want it to do is, I want the frmSystemPrepCh ecklist to open with the same user information that was in the prevous form, frmSearchUsers.
I tried the following code: -
Private Sub Command57_Click()
-
Dim stDocName As String
-
Dim strLastName, strUserName, strFirstName, strModelName, strComputerName As String
-
Dim strChargeCode, strBusinessPhone, strAssetNumber, strSerialNumber As String
-
stDocName = "frmSystemPrepChecklist"
-
-
'Store the calling form's (frmSearchUsers) Lastname, FirstName and
-
'UserName, ModelName, ComputerName, AssetNumber, SerialNumber
-
'and ChargeCode, to add to new reocrd in 'frmSystemPrepChecklist', if needed
-
strLastName = Me!LastName
-
strUserName = Me!UserName
-
strFirstName = Me!FirstName
-
strModelName = Me!ModelName
-
strComputerName = Me!ComputerName
-
strChargeCode = Me!ChargeCode
-
strBusinessPhone = Me!BusinessPhone
-
strAssetNumber = Me!AssetNumber
-
strSerialNumber = Me!SerialNumber
-
-
'Open "frmSystemPrepChecklist", goto the matching UserName field, and set the focus to it.
-
'Note: the strUserName at the end of the following line is the OpenArgs property.
-
'It is the UserNmae I wish to locate in 'frmSystemPrepChecklist' and is by the DoCmd.FindRecord
-
DoCmd.OpenForm stDocName, , , , acFormEdit, , strUserName
-
Forms!frmSystemPrepChecklist!mainUserName.SetFocus
-
-
'Assign frmSystemPrepChecklist mainUserName to a temp variable
-
strmainUserName = Forms!frmSystemPrepChecklist!mainUserName
-
-
'Find the first record in table2 (frmSystemPrepChecklist,
-
'that matches the UserName
-
DoCmd.FindRecord strUserName, , True, , True, , True
-
-
'If the UserName's do not match (not found in tabel2, then
-
'this must be a new record so add a new record and
-
'populate the listed fields of 'frmSystemPrepChecklist
-
-
If strmainUserName <> strUserName Then
-
DoCmd.GoToRecord , , acNewRec
-
Forms!frmSystemPrepChecklist!LastName = strLastName
-
Forms!frmSystemPrepChecklist!FirstName = strFirstName
-
Forms!frmSystemPrepChecklist!UserName = strUserName
-
Forms!frmSystemPrepChecklist!BusinessPhone = strBusinessPhone
-
Forms!frmSystemPrepChecklist!ModelName = strModelName
-
Forms!frmSystemPrepChecklist!ChargeCode = strChargeCode
-
Forms!frmSystemPrepChecklist!ComputerName = strComputerName
-
Forms!frmSystemPrepChecklist!AssetNumber = strAssetNumber
-
Forms!frmSystemPrepChecklist!SerialNumber = strSerialNumber
-
End If
-
End Sub
-
But couldn't get it to work
Help please!
Thanks,
9 3407 maxamis4 295
Recognized Expert Contributor
So let me get this correct. You want to use the first and last name to populate your data in your data base from outlook? I am getting this correct.?
Hmm not sure if I understand your question as simple as it is. Lets see if i can clarify for you. When I push the cmdAdFromOutloo k button it opens the search window in outlook. I type in the users name I looking for then click add and it automatically adds it to my tblContacts. BUT on my form frmSearchUsers, instead of populating the fields with the NEW user that was just added it goes to the first user in the table. I want it to be populated with the user i just added.
There ia a macro running. The first one is the AddFromOutlook macro wich is built in to Access.
As it stands now the user has to go to acombo box on the form and search for the new user. When the name is selected it then fills in the fields with the correct data.
Then the user will push a button titled cmdSystemPrepCH ecklist wich will open the frmSystemPrepCh ecklist. But again the frm opens to the first record in the tblCOntacts instead of the record that is displayed in the prior form frmSearchUsers. I want the second form to open to the information displyed in the prior form.
Does that help explain it? I hopeso. Thanks for interest and resposne!
If I understand you correctly, I think you made it way more complicated then you needed to. You don't want to add a new record, you just want the second form to display the same info as the search form. The openform command has an argument that allows you to place the equivalent of a where clause, so here is all you need to do. I am assuming UserName is the key to the records in both Table1 and Table2; if it isn't substitute the record key for UserName.
Don't close frmSearchUsers until you have opened the frmSystemPrepCh ecklist in your cmdSystemPrepCh ecklist_Click() event. -
Private Sub cmdSystemPrepChecklist_Click()
-
DoCmd.OpenForm "frmSystemPrepChecklist", , ,"[UserName] = "' & Forms!frmSearchUsers!UserName & "'"
-
DoCmd.Close acForm, "frmSearchUsers"
-
End Sub
-
Run-time error '3075':
Syntax error (missing operator) in Query expression '[UserName]='.
Would it be because UserName is not a field on the frmSystemPrepCh ecklist?
Doo i need to add it? and make it invisable to the user?
No, I think the problem is that I have a single and double quote in the wrong order.
Change this part of line 2:
"[UserName] = "' >>> double quote, then double quote/single quote
To this: "[UserName] = '" s/b double quote, then single quote/double quote
-
Private Sub cmdSystemPrepCheck_Click()
-
DoCmd.OpenForm "frmSystemPrepChecklist", , , "[UserName] = "" & Forms!frmSearchUsers!UserName & """
-
DoCmd.Close acForm, "frmSearchUsers"
-
End Sub
-
Above code will open the new form but it opens blank
You did not follow the instructions I gave you.
Change this part of line 2 in the code:
>>>>>>"[UserName] = "" & Forms!frmSearch Users!UserName & """
To This:
>>>>>>"[UserName] = '" & Forms!frmSearch Users!UserName & "'"
If the above correction does not fix it, make sure UserName is a control on the form frmSearchUsers. If UserName is on the form, it should work whether the control is visible or not visible.
ITS ALIVE!!!
lol
It works - Thanks PuppyDogBuddy!
You're welcome. Glad you got it working!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: nadir b |
last post by:
hi
I don't know how to change for exemple a form1 caption text from form2
don't forget that form2 has created from form1
I want sample code with c#
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
|
by: ematrix |
last post by:
|
by: PAPutzback |
last post by:
Form2 has one purpose to open and list some names and ids. I want to
handle the list box click event on form2 so I can get the selected
value onto a field in form1.
I changed this
Dim MyForm2 As New PHfx.Form2
to
With Events MyForm2 As New PHfx.Form2
and tried adding an event handler but intellisense will not show form2s
objects, just the methods.
|
by: Richard |
last post by:
Hello there,
I have a form that is called from a Sub Main procedure using
application.run(Form1).
On my main form there is a button to open an instance of Form2 and
then at the same time hide Form1.
So far so good.
|
by: John |
last post by:
Hi,
I can't find a simple example for a simple(?) problem.
I am working on an application with a variable in form1, that variable
is needed in form2 for a calculation but i can't get that variable in
form2.
Is there a simple method (in VSexpress2005) to get that specific
variable in form2?
TIA,
| |
by: Karan |
last post by:
I am calling finalize when form2 loads and deactivates form1 which closes
form1. However, same thing is not happening in form2 because finalize is
already called. Does anybody has solution to it. This code works well for
splash screen. I searched alot on net for codes but they don't work. for
example-
(1)
Public Sub CloseForm(formType As System.Type)
For Each oForm as System.Windows.Forms.Form in me.MdiParent.MdiChildren
If...
|
by: R. Harris |
last post by:
Hi.
I have 2 forms:
form1
form2
On Form2 I have a listbox and a button. When I click the button it calls a
function from form1 and within that function it updates the listbox on
form2.
My problem is I don't see the items added to the listbox unless I use
|
by: Luvin lunch |
last post by:
Hi All,
I have a grid (i.e. continuous form) on Form1, that opens a second form
(not a subform) Form2 when the user double clicks on it. On form2 the
user can save information. When the user selects Save, I want to
reload Form1 because the changes in Form2 will change the order that
records should appear on Form1. I have implemented this functionality
as follows:
Private Sub cmdSave_Click()
|
by: GoGs |
last post by:
HEEEELLLLLPP
I hawe two Open form... Form1 and Form2
How I can from Form2 send text to textbox of Form1
//public System.Windows.Forms.TextBox textBox1;
//Form1 fo = new Form1();
//fo.textbox1.Text = "something";
--Don't work
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |