473,698 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use a variable for field name in vba

2 New Member
The following assignment of data works well…

rsadd![SName] = rs![Sname]

However, I need to substitute a variable, (eq. NF which has the value Sname) into the field name position of the rsadd![SName]=rs!________ line. I cannot get the syntax correct. Any help would be appreciated.
Sep 25 '11 #1
3 27307
ADezii
8,834 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. strFieldName As String
  2.  
  3. strFieldName = "<Some Field Name>"
  4.  
  5. rsadd![SName] = rs.Fields(strFieldName)
  6.  
Sep 25 '11 #2
mike820
2 New Member
Perfect... Perfect... Perfect...

Yea... Yea... Yea...
Sorry, I am repeating myself. Just so excited to get a complete, understandable, useable reply. Thanks so much.
Sep 26 '11 #3
ADezii
8,834 Recognized Expert Expert
You are quite welcome.
Sep 26 '11 #4

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

Similar topics

4
1938
by: Stuart Palmer | last post by:
Hi everyone, I have a form with '/' in some of the field names, when I pass through to the next page the field name comes back as though it's been htmlencoded, so getting the value out of the field I need to convert this back to '/' with the replace (same problem if I have a ',' in the name) Is there an easy way to htmldecode or something what it converted to the encoded versions? (I have written a short function to basically do all my...
7
2156
by: Consuelo Guenther | last post by:
Hello, I have an asp page that has a function that connects to an Access database. I am using Javascript. Is there any way to reference the field name in the database through a variable in a sql statement? For example, in my function I have: var dayofWeek = "Friday"; var sSQL = "";
2
4687
by: ~TheIcemanCometh~ | last post by:
I have 2 questions. I am trying to write a stored procedure to update a table. I am trying to pass a variable that represents the name of the column/field and another for the value that I am changing. For example: @FieldName VARCHAR(100) @FieldValue VARCHAR(100) AS
2
4799
by: Bob Alston | last post by:
I have a database with user definable fields. These are in the table as Field1, Field2, etc. I store the labels in another place and on the form, I display the labels they designate instead of the generic "Field1". I want to create a query that will have the user defined field as the column name, instead of Field1, Field2, etc. Any easy way to do this? Access won't let me insert a field name into the name of a query e.g. : field1
7
27579
by: rpeacock | last post by:
I was curious to know if it is possible to run an Update query by passing the field name as a variable for updating. The simple example should make more sense. Basically I am trying to change the color stored in the field by passing the current color @value, the field name @field, and the scheduleID @scheduleID. If I make the @field in the update column an actual field name versus putting @field, the update works fine. I just don't know...
1
4546
by: john | last post by:
LINQ works a lot like an Access DB Recordset in the way it functions, one of the things I could do in Access is refer to the Fields thru a Variable as below allowing me to Iterate over the Recordset with a test or slight change to field names. Is there a way to Replicate this Method in LINQ, I've tried setting the Variable as an Object "Dim tDayID AS Object = "tem.Day" & 1" but it did not work? IN ACCESS: Dim DaI As String DaI =...
6
3344
by: kpfunf | last post by:
Ok, I hope I can explain this one well enough! I have tables that contain similar data but are not all uniform; I use queries to create uniform data sets (same field names, formatting, etc.). I have a process that needs to update records in the original table. However, I cannot simply refer to a field name to update, as it can vary amongst the tables. My idea is to take a piece of data (in my example, an aircraft tail number, assigned to...
3
2993
by: adiel_g | last post by:
Hello everyone, I am trying to move a field name to a variable in vb.net. For example, first I retrieve the record from the database and save its value: .... userGroup = ds.Tables("Default").Rows(x).Item("UserGroupAccess").ToString 'retrive access value from dataset ....
19
1869
by: JRough | last post by:
I have used this function to create a string called $headers: function GetHeaders($file_name){ return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th> <th><a href='". $file_name."&order_by=carnumber'>Carnumber</a></th> <th><a href='". $file_name."&order_by=location'>Location</a></th> <th><a href='". $file_name."&order_by=sighting_date_asc'>Sighting
5
9711
by: parry2k | last post by:
I have one view with 3 fields like the view name is myview and it has following sql statement. select fn,ln,city from tablea I created a function like below:- create function myfun(in t myview, in f varchar(50)) returns varchar(100) as Now i want to pass row and name of field and let it return the value from function on basis of field name i pass to the function like
0
9157
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
9028
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...
0
7728
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.