473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to use a variable for field name in vba

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 27153
ADezii
8,834 Expert 8TB
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
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 Expert 8TB
You are quite welcome.
Sep 26 '11 #4

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

Similar topics

4
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...
7
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...
2
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...
2
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...
7
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...
1
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...
6
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...
3
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 =...
19
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='"....
5
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.