473,729 Members | 2,355 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 27326
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
1942
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
2160
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
4688
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
4802
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
27590
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
4550
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
3346
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
2997
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
1874
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
9720
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
8917
marktang
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...
0
8761
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,...
1
6722
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
6022
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
4525
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
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
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.