473,734 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto fill field from value in Report

147 New Member
I have a Report in which I have one of the fields set up to launch a form with the On Click event. I would like to have the form launch and auto fill a field with the value of the field clicked in the report. For example in the report I click the name John Jones in the Name field, the form launches and I want the name John Jones entered in the Name field of the report.

Any ideas So far I have this in the on click event of the field in the report:
Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2.  
  3. stDocName = "frmAssignEquip"
  4. DoCmd.OpenForm stDocName
  5. DoCmd.Close acReport, "rptAssignedEquip"
Thanks for any help
Dan
Jan 26 '08 #1
9 4288
Jim Doherty
897 Recognized Expert Contributor
I have a Report in which I have one of the fields set up to launch a form with the On Click event. I would like to have the form launch and auto fill a field with the value of the field clicked in the report. For example in the report I click the name John Jones in the Name field, the form launches and I want the name John Jones entered in the Name field of the report.

Any ideas So far I have this in the on click event of the field in the report:

1. Dim stDocName As String

2. stDocName = "frmAssignEquip "
3. DoCmd.OpenForm stDocName
4. DoCmd.Close acReport, "rptAssignedEqu ip"


Thanks for any help
Dan
Dan,

Slightly confusing..repo rts don't have an on click event! are you referring to a form here?

Jim
Jan 26 '08 #2
DAHMB
147 New Member
Dan,

Slightly confusing..repo rts don't have an on click event! are you referring to a form here?

Jim

Hi,
Yes it is definately a report. I am using Access 2007 maybe it is new to this version. But I would asume it would work the same in a report as in a form (hopefully). Any ideas?
Thanks
Dan
Jan 26 '08 #3
missinglinq
3,532 Recognized Expert Specialist
Exactly how would you "click" on a textbox on a Report, using a paper mouse perhaps? I'm sorry, Dan, but Jim is correct! Access 2007 has a lot of new features, but controls on Reports with Click events are not among them!

Linq ;0)>
Jan 26 '08 #4
DAHMB
147 New Member
Exactly how would you "click" on a textbox on a Report, using a paper mouse perhaps? I'm sorry, Dan, but Jim is correct! Access 2007 has a lot of new features, but controls on Reports with Click events are not among them!

Linq ;0)>

Missingling you are wrong and being sarcastic is only makes you sound worse. I have a Report in Access 2007, in the report I have a text box and under Event of the text box there is an on click feature. I have it set up to open a form and it works. That being said does anyone have an answer to my original question? Please solutions only I don't have time for negatives.
Jan 26 '08 #5
DAHMB
147 New Member
Missingling you are wrong and being sarcastic is only makes you sound worse. I have a Report in Access 2007, in the report I have a text box and under Event of the text box there is an on click feature. I have it set up to open a form and it works. That being said does anyone have an answer to my original question? Please solutions only I don't have time for negatives.

As proof to all the doubters view the MS Access 2007 student Sample database!!!!!!
Jan 26 '08 #6
Jim Doherty
897 Recognized Expert Contributor
Hi,
Yes it is definately a report. I am using Access 2007 maybe it is new to this version. But I would asume it would work the same in a report as in a form (hopefully). Any ideas?
Thanks
Dan
OK Dan... well you caught me on that one I don't personally use the new Access 2007 version (support all previous versions but not the new one just yet ) events for textboxes in reports for Access 2007 are indeed there for on click (and others) so you are right and I am wrong. I apologise for not knowing this you have now taught me something.

Anyway,,,, the principles will be the same for the purposes of navigating around a system in that you can open a form from a form and also now in Access 2007 a form from a report with an 'on click' event. So how would we do that? well in much the same way as we do with form to form in that you would define some criteria to establish a link between the record you are clicking in the report and the record you wish to see in the form

So...

Expand|Select|Wrap|Line Numbers
  1. Dim stLinkCriteria
will define a variable of variant to store the value we wish to use in the navigation sequence (you could define it as a string or number type if we know the data type of the field we are using) but lets say for the moment that the field we are going to use is called ID

We then define what that stLinkCriteria will be by stating it thus:

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria= "[ID]=" & Me!ID
Me!ID relates to the field on the report called ID and the left side of the equals sign is the field on the form we intend opening that is called ID also

We then issue the command passing WHERE clause criteria to the openform command so that the form opens to the relevant record we wish to see

Expand|Select|Wrap|Line Numbers
  1.  DoCmd.OpenForm "frmAssignEquip",,,strLinkCriteria
The idea then is to pass the value of the 'Name' field you mention to the corresponding 'Name' field on the form which is done like this

Expand|Select|Wrap|Line Numbers
  1.  Forms!frmAssignEquip![Name]=Me![Name]
Once the value has been passed we can then close the report (which is still open at this point) leaving only the form itself open

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close acReport Me.Name, acSaveNo
(The acSaveNo segment of the close action on the last line tells access to close the report and disregard any changes that you might have made within the body of the report itself at some time during the time it has been currently open without prompting the user. Incidentally you can refer to the 'name' property of the report itself explicitly if your code is behind the report from which your code is executing.....M e.Name)

So revising this then to achieve what you need... the entire code block will be this

Expand|Select|Wrap|Line Numbers
  1.  Dim stLinkCriteria 
  2. stLinkCriteria= "[ID]=" & Me!ID
  3. DoCmd.OpenForm "frmAssignEquip",,,strLinkCriteria
  4. Forms!frmAssignEquip![Name]=Me![Name]
  5. DoCmd.Close acReport Me.Name, acSaveNo
  6.  

As an additional it is never a good idea to use words describing fields that Access likes to keep to itself 'reserved' words in other words for naming fields. You are obliged to wrap them in square brackets in much the same way as if you have spaces in field names. It just makes for extra work for yourself and others who might have to read syntax strings where you see some having brackets and others not....its a general standard I'm talking about here not an obligation.


Kind Regards

Jim :)
Jan 27 '08 #7
NeoPa
32,569 Recognized Expert Moderator MVP
Subscribing .
Feb 2 '08 #8
DAHMB
147 New Member
OK Dan... well you caught me on that one I don't personally use the new Access 2007 version (support all previous versions but not the new one just yet ) events for textboxes in reports for Access 2007 are indeed there for on click (and others) so you are right and I am wrong. I apologise for not knowing this you have now taught me something.

Anyway,,,, the principles will be the same for the purposes of navigating around a system in that you can open a form from a form and also now in Access 2007 a form from a report with an 'on click' event. So how would we do that? well in much the same way as we do with form to form in that you would define some criteria to establish a link between the record you are clicking in the report and the record you wish to see in the form

So...

Expand|Select|Wrap|Line Numbers
  1. Dim stLinkCriteria
will define a variable of variant to store the value we wish to use in the navigation sequence (you could define it as a string or number type if we know the data type of the field we are using) but lets say for the moment that the field we are going to use is called ID

We then define what that stLinkCriteria will be by stating it thus:

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria= "[ID]=" & Me!ID
Me!ID relates to the field on the report called ID and the left side of the equals sign is the field on the form we intend opening that is called ID also

We then issue the command passing WHERE clause criteria to the openform command so that the form opens to the relevant record we wish to see

Expand|Select|Wrap|Line Numbers
  1.  DoCmd.OpenForm "frmAssignEquip",,,strLinkCriteria
The idea then is to pass the value of the 'Name' field you mention to the corresponding 'Name' field on the form which is done like this

Expand|Select|Wrap|Line Numbers
  1.  Forms!frmAssignEquip![Name]=Me![Name]
Once the value has been passed we can then close the report (which is still open at this point) leaving only the form itself open

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close acReport Me.Name, acSaveNo
(The acSaveNo segment of the close action on the last line tells access to close the report and disregard any changes that you might have made within the body of the report itself at some time during the time it has been currently open without prompting the user. Incidentally you can refer to the 'name' property of the report itself explicitly if your code is behind the report from which your code is executing.....M e.Name)

So revising this then to achieve what you need... the entire code block will be this

Expand|Select|Wrap|Line Numbers
  1.  Dim stLinkCriteria 
  2. stLinkCriteria= "[ID]=" & Me!ID
  3. DoCmd.OpenForm "frmAssignEquip",,,strLinkCriteria
  4. Forms!frmAssignEquip![Name]=Me![Name]
  5. DoCmd.Close acReport Me.Name, acSaveNo
  6.  

As an additional it is never a good idea to use words describing fields that Access likes to keep to itself 'reserved' words in other words for naming fields. You are obliged to wrap them in square brackets in much the same way as if you have spaces in field names. It just makes for extra work for yourself and others who might have to read syntax strings where you see some having brackets and others not....its a general standard I'm talking about here not an obligation.


Kind Regards

Jim :)




Jim,

Thank you very much that was it!!!!!! Sorry for the delayed thanks I was away.
Feb 4 '08 #9
Jim Doherty
897 Recognized Expert Contributor
Jim,

Thank you very much that was it!!!!!! Sorry for the delayed thanks I was away.
You,re welcome

Jim :)
Feb 4 '08 #10

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

Similar topics

2
2194
by: David P. Donahue | last post by:
I'm using the following code to add a row to a table (for holding images) in my database (obtained from http://www.codeproject.com/aspnet/image_asp.asp?df=100&forumid=38225&select=1038401): public string AddImage(byte buffer, string contentType) { string strSql = "SELECT * FROM WebImages"; DataSet ds = new DataSet("Image"); OdbcDataAdapter tempAP = new OdbcDataAdapter(strSql, this._objConn); OdbcCommandBuilder objCommand = new...
1
6588
by: ogilby1 | last post by:
Using an immediate if to fill a field on a form based on the value of another field. During data entry on the form this methodology works well. When looking at the results in the datasheet view or the underlying table this immediate if field contains the default value that was set when originally setting up the table and the form. =IIf(=10100100, "CR", "DB") => this works well in the flow of the form but does not actually populate the...
4
4713
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
4
10649
by: the hotshot | last post by:
hello, this seems to be a hard question so far and noone has been able to help with this. is it possible to have access start an autonumber with a prefix according to the year when the data is entered. for example, if i entered something in 2004, i would like the number to bigin with 2004003, 2004004, 2004005... and same for 2005001, 2005002...? much and great appreciation for suggestions. thank you,
4
10244
by: Shahar | last post by:
Hi I need to get a field name 'ID'(that is an auto-number field) right after I add a new row to table, it's work like that: myCommand.ExecuteNonQuery(); myCommand.CommandText = "SELECT @@Identity"; // the auto-number fiels int iId = (int)myCommand.ExecuteScalar();
8
30417
by: John | last post by:
Hi, I am developing an application using VB.Net and hope that the textbox can process features which are similar to auto-complete features in Window. For example, when user types "ap" in a textbox and the data associated to the textbox contains ("apple", "applet", "application"......), the application will suggest "apple" to the user to select and user can either select the suggestion or continue to type another word he disires. How...
0
2695
by: KelHemp | last post by:
Greetings, I've been using this site for lots of access help in the past, and it's very helpful! I have a new complexity for you all. Reworking a form to record 70-80 years of oil production on multiple leases, which have multiple wells within them. Most wells can fit on one printed page (one record), but in the case of overspill, we want to do the following: -Move to a new record and auto fill the LeaseName, LeaseNumber, Operator,...
3
2461
by: JDubP | last post by:
I know a bit about VBA in Excel, but not about looping records in Access 2003, so any help will be appreciated. I think if someone can send me some sample code, I can muddle my way through. (or if you can send me alink to read how to do it that is fine also) I presently run a macro that: 1) runs a query where User has to input a value for field and 2) prints/saves a report in snapshot view (i have to manually type in file name) I...
106
19804
by: bonneylake | last post by:
Hey Everyone, Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all gladly delete my question an put it in the correct section. Well what i am trying to do is pretty simple. I have a input field and someone starts typing in a customer number. As they type in the customer number the drop down box is populated. They...
0
9449
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, 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...
0
9310
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
9236
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,...
1
6735
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 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...
0
6031
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
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...

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.