vba select field

Hi,
having a button on a form, is it possible to select only some fields
(all from the same table) of the current record instead of all fields?
I've tried this code:

RunCommand acCmdSelectRecord
RunCommand acCmdCopy
Forse dipende dei dati nel record.

but it selects ALL fields in the form.
Thank you.

Remigio
0
remigio
4/10/2010 4:01:56 PM
access 16762 articles. 3 followers. Follow

5 Replies
4570 Views

Similar Articles

[PageSpeed] 31

hi,

On 10.04.2010 18:01, remigio wrote:
> having a button on a form, is it possible to select only some fields
> (all from the same table) of the current record instead of all fields?
> I've tried this code:
>
> RunCommand acCmdSelectRecord
> RunCommand acCmdCopy
> Forse dipende dei dati nel record.
>
> but it selects ALL fields in the form.
Yes, you need to run an append query. Create one with the query designer:
Add your table where your form is based on. Change the query type to an 
append query. Select the fields you only want to append. Add the primary 
key field and add a condition to it. Use the wizard to build a form 
reference to your current form.

   http://office.microsoft.com/en-us/access/HA100765271033.aspx

Store the query. You can then run it using

   DoCmd.RunQuery "yourQuery"


mfG
--> stefan <--
0
Stefan
4/10/2010 5:17:42 PM
In addition, you might find this article helpful:

    Assign default values from the last record
    http://allenbrowne.com/ser-24.html


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

"Stefan Hoffmann" wrote:

> hi,
> 
> On 10.04.2010 18:01, remigio wrote:
> > having a button on a form, is it possible to select only some fields
> > (all from the same table) of the current record instead of all fields?
> > I've tried this code:
> >
> > RunCommand acCmdSelectRecord
> > RunCommand acCmdCopy
> > Forse dipende dei dati nel record.
> >
> > but it selects ALL fields in the form.
> Yes, you need to run an append query. Create one with the query designer:
> Add your table where your form is based on. Change the query type to an 
> append query. Select the fields you only want to append. Add the primary 
> key field and add a condition to it. Use the wizard to build a form 
> reference to your current form.
> 
>    http://office.microsoft.com/en-us/access/HA100765271033.aspx
> 
> Store the query. You can then run it using
> 
>    DoCmd.RunQuery "yourQuery"
> 
> 
> mfG
> --> stefan <--
0
Utf
4/10/2010 7:16:01 PM
....
 Add the primary
> key field and add a condition to it.

What type of condition?

Use the wizard to build a form
> reference to your current form.

A form reference? May you explain to me how to operate?

In substance II have to subsitute the posted code with your

DoCmd.RunQuery "yourQuery"

is it correct?

Thank you very much.

Remigio
0
remigio
4/11/2010 7:05:55 PM
hi Remigio,

On 11.04.2010 21:05, remigio wrote:
>   Add the primary
>> key field and add a condition to it.
> What type of condition?

> Use the wizard to build a form
>> reference to your current form.
> A form reference? May you explain to me how to operate?
Have you read the links (also Tom's) and tried the examples?


mfG
--> stefan <--
0
Stefan
4/11/2010 9:26:34 PM
> Have you read the links (also Tom's) and tried the examples?

Yes, I have.
I'm also able to create and run an update query (it seems this the
article referres).
I only please you to explain me what "... and add a condition to it.
Use the wizard to build a form
reference to your current form. " means, maybe with an example.
Thank you very much for help.

Remigio

0
remigio
4/14/2010 3:29:43 PM
Reply:

Similar Artilces:

Proportion of Fields filled
Hi, How to calculate the percentage of filled fields by number of records in order to know what field has been most filled Thanks, Carla -- Message posted via http://www.accessmonster.com So you want to show the percentage of records that have some value (any value) in a particular field? 1. Create a query. 2. Depress the Total button on the toolbar. Access adds a Total row to the design grid. 3. Drag the primary key field into the grid. In the Total row under this field, choose Count 4. Drag your other field(s) into the grid, choosing Count again. This gives you the count of all rec...

cannot create new fields in CRM
Hi There, we are having issue wher we can no longer add new attributes, we get the error message saying "An error has occoured, for more information contact your administrator." As far as we know we haven't done anything that could have caused it, we are running small business server 2003 and CRM version 3.0 Rgds, Kyaw is the System Customizer role deleted? if it is, add the role back using the script found here: http://groups.google.com.sg/group/microsoft.public.crm.developer/browse_thread/thread/826a19aab8ff173a/80d124150a51875c?lnk=st&q=mscrm+customizer+role+de...

changing cbobox row source through vba code
Hi All, I have a frame which has 2 option.Option 1 and 2. I also have a combo box. I want when option 1 in my frame is clicked, my combo box row source is "SELECT [List Model DC Query].[Model DC Fan] FROM [List Model DC Query], [Model AC Query] ORDER BY [List Model DC Query].[Model DC Fan];" and when the 2nd option of frame is clicked,it row source becomes "SELECT [Model AC Query].[Model DC Fan] FROM [List Model DC Query], [Model AC Query] ORDER BY [Model AC Query].[Model DC Fan];" please help to write the code and on what control even have to be placed. regards, cho ...

calculating multiple fields in an unbound text box
I have a report based on a query that links 2 tables by the field "Type". Each tiype in the one table has a minimum price. The other table has the type and actual sales prices in four different fields of which only one is used in the calculations. I am calculating the difference between actual selling price and minimum price. the problem I am having is that although the minimum price is always desplayed for the type, the calculation does not work for the different fields. If the first field is null, then the next 3 fields should be checked. The other fields may or may not be ...

mouse selection of shapes
Hi all, I would like to run some vba code when the user selects a shape or an image. the procedure selectionchange() seem not to be useful with shapes but only with cells... can you please help me? thanks marco Right click your shape and choose assign macro, this won't work of course for new shapes that the user may put on the sheet that haven't had a macro assigned. -- -John http://www.jmbundy.blogspot.com/ Please rate when your question is answered to help us and others know what is helpful. "perf" wrote: > Hi all, > I would like t...

Help about numeric type field. Thanks.
I created a SQL Server 2005 CE DB ( .sdf, version 3.0) with vs2005. And I created a table which has 2 fields: fld1 - int, fld2 - numeric(38,25). But I encounted an error messagebox when I tried to insert a record (4005,9000000). The msgbox said Conversion overflows. The setting for my numeric fld2 is (precision=38,scale=25). So why occur error when to insert 9000000? Thanks in advance. ...

Sorting selection
In my checking account display I have selected to have my account sorted by date (Increasing). Every few days, of its own volition, it switches to sorted by date (Decreasing). How can I stop this irritation. Thanks, Len Urban ...

OLE field on form
How do I get an ole field on a form to display full frame. At the moment, all I can get it to do is show a small (and rather blocky) verion of a .bmp file, with the file name underneath. It won't display .jpg at all - only the file name. I've played with this for a while now. "Paul Doree" <PaulDoree@discussions.microsoft.com> wrote > How do I get an ole field on a form to display full frame. > At the moment, all I can get it to do is show a small (and > rather blocky) verion of a .bmp file, with the file name > underneath. It won...

Need to import select Access data into Excel using two variables
I have a large amount of data in Access, more than Excel can manage. The data consists of many columns; has Col_1 as unique key 1,2,3,4,5,6,7,8 etc… and contains data that includes Col_2, Col_3, Col_4 etc…. It takes a combination of Col_2 and Col_3 to get the data I want. Col_2 has duplicate values and Col_3 makes the subset unique. One more thing… Col_3, Col_4 etc…may have blanks throughout the table and can’t be changed. I don’t own it. I want to be able to open Excel, type “Number from Col_2” into Col_A , “(Number fromCol_3) or (blank)”into Col_B and have the Col_4, Col_5 etc… d...

VBA and Report Security
I work as a consultant that writes reports in access for an accounting program based on access. I already know how to secure the VBA Code behind my reports but would like a way to prevent my report from running if the report database is copied by another consultant and my report is imported into another database. Could I add a line of code into my reports that would confirm something like: IF Filename = Smith.mbd Then Continue Else Stop? This way if someone copied my report into another report databse for a different Client the report would not run. AccountingLabs wrote: > I work...

Best way to get started with VBA?
Hi. A lot of replies by the MVPs include the statement that the OP will need to use VBA. What's the best way to get started? Are there any "VBA for Dummies" type books or development tools? Are there repositories of source code that the beginning VBA programmer can look at? Question: Does Outlook (2003) out of the box contain VBA code that is executed when a user clicks on a button or fills out a form? While Outlook is running, is there a way to watch this code execute and see how it changes values or fills in fields? This question came up in my mind because of the dedica...

To many fields defined error message
I am currently using access 2003 and when I am attempting to bring multiple queries together into one... I am getting a To many fields defind error message. Below is my SQL that I currently have. I am going to want to add another 30 fields from 3 other queries to this one as well. SELECT [Employee Hierarchy - Current Month].[Performance Year], [Employee Hierarchy - Current Month].[Performance Month], [Employee Hierarchy - Current Month].ATTUID, [Employee Hierarchy - Current Month].Skill, [Employee Hierarchy - Current Month].Ramp, [TC-All-Weeks].[TC-Week1-Step2].[Trans and Co...

Extracting Data from Access dB to Excel, using VBA
Hi All, Firstly, I'm an amateur on a steep learning curve, so please excuse me if some of my terminology/understanding is incomplete. I have found a VBA procedure which will extract entire tables from a db to a grid array in an excel spreadsheet. The procedure relies on two cell values, one identifies the database path, the other identifies the required table. When the procedure is run, it evaluates the two values and returns the specified table in its entirety. The problem I am having is that it works perfectly for tables that have no 'dead-space', ie blank fi...

Convert from Excel and change field to Autonumber
Hi, I have an Excel file which I have opened in Access to create an access table which is fine. I am now quickly going through the fields to tweak them to what they should be but the Excel file was created from a Lotus Approach database that had a field which was autonumber. Obviously when I try to change the field in the Access database it tells me that it can not do this as there is data in the table. What is the proper procedure to do this and either make the field an autonumber field during conversion or after? -- Dan Pickard ----------------------------- Powerful Windows 2003 ...

How to un-concatenate a field with full name
I have a filed called "Contact" that has the full first and last name - is there a way to break this field into 2 fields - "first name", 'last name" ??? How do you find where to split the field? Thanks Take a look at "InStr" function in vba -- sam "Patricia" wrote: > I have a filed called "Contact" that has the full first and last name - is > there a way to break this field into 2 fields - "first name", 'last name" ??? > How do you find where to split the field? > > Thanks Patricia GOOD ...

What exactly is "frequently-used text fields" looking in?
Gurus, Running Outlook 2003. When you do an "Advanced Find" anywhere in the Folder Tree you get three choices at the top underneath "Search for words" subject field only subject field and message body frequently-used text fields What exactly is "frequently-used text fields" looking in? -- Spin it depends on the item type you are searching for. In contacts, it's name and address and notes field. -- Diane Poremsky [MVP - Outlook] Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/...

Re: Access VBA Query Def.
Jedireg wrote: OK.... so I've finally found out that I can't use the runsql command with a select statement. Which leaves me trying to figure out how to do this with ADO. Any help would be greatly appreciated. however I can not get the follow sql to work in a saved query def either. SELECT tblPart_Info.Rev_Date, tblPart_Info.USL, tblPart_Info.LSL, tblPart_Info.Max_RA, tblPart_Info.Out_Of_Square, tblPart_Info.Crown, tblPart_Info.Comments FROM tblPart_Info WHERE (((tblPart_Info.Part_No)=[Forms]![Main]![cboPartNum].[Text]) AND ((tblPart_Info.Rev_Level)=[Forms]![M...

Give me all rows that exist in SELECT 1 that don't exist in SELECT 2
I have two slightly different select statments, each with the same columns in the SELECT list. How can I say: Give me all rows that exist in SELECT 1 that don't exist in SELECT 2. I know that there are many rows that have duplicate rows in SELECT 1 but only a single example in SELECT 2. I would like my result set to have that extra row from SELECT 1. Thanks. Rick http://dimantdatabasesolutions.blogspot.com/2007/02/dealing-with-duplicates.html WITH select1 AS ( SELECT <columns> FROM ... ),select2 AS ( SELECT <columns> FROM ... ) SELECT * FROM select1 WH...

Numeric Field Overflow Error
Hello, I have a table in my database that is liked to an excel file. The data type of every field of the linked table is 'text'. I have created another table that I will append the information to via an append query. This secondary table has the same fields and the same data types - all 'text'. When I try to run the append query, it may work one time and then error out saying, "Numeric Field Overflow." My question is - How do I fix this error so that the query will run consistently? Why does it sometimes append and othertimes give me the 'Num...

group/sort on 2 fields w/ same value
I need to have my report group/sort multiple records based on two different fields having the same value. It's ticketing system and there is a Primary and Secondary individual assigned to each ticket. I'm trying to build a report that will group and list all records where an individual is listed as EITHER the Primary OR Secondary. This will, obviously, end up listing some ticket records twice and that is okay and what I need (listed once under the Primary resource and again under the Secondary resource). Help? Have a main form and 2 subforms. The primary and secondary would ...

Calculated field in pivot table #4
I'm running Excel 2002. I'm unable to create a calculated field in a pivot table. I right-clicked on a cell in the table but I don't get the "Insert Calculated Field" window on my drop-down list. Do I need an Add-On? Am I doing something wrong? Thanks for any help. On the PivotTable toolbar, choose PivotTable>Formulas>Calculated Field Dan wrote: > I'm running Excel 2002. I'm unable to create a calculated field in a pivot > table. I right-clicked on a cell in the table but I don't get the "Insert > Calculated Field" window on my ...

The Selected Task No Longer Exists
Every time I start Task Scheduler, I get a persistent error message notifying me that "The scheduled task 'xxx' no longer exists. To see the current tasks, click Refresh." where 'xxx' is the name of an obsolete task. What is my next step to get rid of this error? Brandon Taylor remove it from your scheduled tasks peter -- If you find a posting or message from me offensive,inappropriate or disruptive,please ignore it. If you dont know how to ignore a posting complain to me and I will be only too happy to demonstrate :-) "Brandon Taylor...

IF field tags in Publisher?
I would like to be able to insert specific text, using IF/THEN statements within Publisher, based on the content of merged data. In other words, if the field "apples" in a merged data source says "red" I want my Publisher document to print "You're lucky your apples aren't green!", or if the "apples" field says "green" then I want it to print "How about them apples!". You get the idea. I think this is possible using mail merge in Word, with the IF field tag. Is this possible in Publisher? Thanks! ...

Set form field on double click
I am using MS Access 2003. I have a continuous form that is run off of a query "srbScientific Review". The query's criteria is set to [Enter Last Name] in the LastName field. That part works fine. I get my continuous form that shows LastName, DocID, and Title of Document. I would like to double click on the DocID and have the following happen: 1. Open another form "publications" 2. Set the SRBId field to the DocId field that I double clicked on. PLEASE help. I think I need to bookmark, clone.... I'm very confused. As a kick in the right ...

Analysis Cubes
Hello Everyone, How do you make User-defined fields available for Analysis cubes? I looked on the KBs but found none that addressed this. Thanks in advance! ...