Hello,
I am trying to refer to fields on a given form from the form query's recordset, essentially from the following commands: -
Dim frm As Form 'Refers to the current form
-
Dim tagName As String 'Refers to the field in the form's recordset (not a control on the form)
-
-
...
-
frm.Fields(tagName).Value 'This gives Error 2465
-
My question is how do I refer to a field in the form's record set (not an individual control on the form)? If I use frm![LineTag].Value, it works fine, but frm.Fields(tagN ame).Value does not. Conversely, rs.Fields(tagNa me) does work fine. (note: tagName="LineTa g")
Please let me know how I can refer to a form's recordset field.
Thanks!
...
For more info and as to why I need it, here is a large chunk of the function I use to call the segments mentioned above: -
Function duplicateRecord(ByRef frm As Form, tableName As String, uniqueCtl As TextBox, tagName As String, ByRef avarExceptionList() As String) As Long Dim rsExist As Recordset
-
Dim keyName As String, keyValue As Long
-
Dim tempRecord As Long
-
Dim fld As Field
-
-
On Error GoTo Err_duplicateRecord
-
Set rsExist = CurrentDb.OpenRecordset(tableName)
-
keyName = uniqueCtl.ControlSource
-
If uniqueCtl.Value > 1 Then
-
keyValue = uniqueCtl.Value
-
If frm.NewRecord Then
-
Call MsgBox("New records cannot be duplicated, please save this record first then try again.", vbExclamation, "Nonexistant Record")
-
duplicateRecord = -1
-
Exit Function
-
ElseIf frm.Dirty Then
-
If MsgBox("Save changes?", vbYesNo, "Unsaved Changes Detected") = vbYes Then
-
MsgBox frm.Fields("LineTag")
-
If isSaveable(tableName, tagName, frm.Fields(tagName).Value, keyName, keyValue) Then 'This gives Error 2465
-
Call saveRecord(frm, keyValue)
-
Else
-
Exit Function
-
End If
-
Else
-
Exit Function
-
End If
-
End If
-
...
-
End Function
-
3 3986 ADezii 8,834
Recognized Expert Expert
I'm actually a little confused about your question, but to Output a List of Fields comprising a Form's Recordset: - Dim rst As DAO.Recordset
-
Dim fld As DAO.Field
-
-
Set rst = Me.RecordsetClone
-
-
For Each fld In rst.Fields
-
Debug.Print fld.Name
-
Next
Sample Output: - EmployeeID
-
LastName
-
FirstName
-
MI
-
Title
-
TitleOfCourtesy
-
BirthDate
-
HireDate
-
Address
-
City
-
Region
-
PostalCode
-
Country
-
HomePhone
-
Extension
-
Photo
-
Notes
-
ReportsTo
To actually refer to Fields within the context of a Form's Recordset, once it has been defined: - rst!EmployeeID
-
rst!LastName
-
rst!FirstName
-
rst!MI
-
rst!Title
-
rst!TitleOfCourtesy
-
rst!BirthDate
-
rst!HireDate
-
rst!Address
-
rst!City
-
rst!Region
-
rst!PostalCode
-
rst!Country
-
rst!HomePhone
-
rst!Extension
-
rst!Photo
-
rst!Notes
-
rst!ReportsTo
Just figured it out, I used:
frm.RecordSet.Fields(tagName )
Thanks for help ADezii, Me.RecordsetClo ne was a good hint.
ADezii 8,834
Recognized Expert Expert
It is usually a good idea to always avoid accessing the actual Form's Recordset in any manner, which is why I always use RecordsetClone whenever appropriate.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: bnp |
last post by:
Hi All,
I am quite new the JavaScript. Basically I am a C++ programmer, but
now I am working on JavaScript since last 5 days.
I have a problem regarding the form validation.
I have created a script that validates the form fields. the validation
procedure is called ONCLICK event of the submit button.
Follwowing is the structure of the validation procedure.
|
by: karenmiddleol |
last post by:
I have the following form the user enters the From and to period and
presses the Submit button and the form fields are cleared once the
submit button is pressed.
Is there a way I can keep the Form fields visible and not cleared.
Also when I display the message I want the original form cleared in a
different version of this page how can I clear the form completely when
I display the data entered from the Response statements I do not...
|
by: Li Zhang |
last post by:
I know I can use controlName.Value to retrieve the form fields value if
I am in that page. But if I am out of the page, for example I am in a
HttpModule, I want to retrieve a hidden filed value, Is that possible?
if so how? Thanks!
|
by: Chuck Anderson |
last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example
and changing those examples to suit my needs. That said ....
..... I have some select fields in a form I created for a database search
that I am unable to figure out how to access. (The search is
implemented in Php/MySQL.)
The user enters search values for: name, address1, city, .... etc.,
..... and for each of these they also select whether the search should...
|
by: Perks |
last post by:
Hi.
I am trying to find out if it is possible to open a pdf file from
within PHP, and parse its contents in order to extract all form
fieldnames that might have been previously setup within the pdf
itself.
I want to find this out so that I can then generate a HTML form with
all required questions, which when submitted, will generate a fdf /
xfdf file, using the techniques from the following tutorial
| |
by: guido |
last post by:
I've written a user control to add form fields to a aspx page:
Private Sub buildFields()
'Label1.Text = "building fields at " & System.DateTime.Now()
Dim themeIDField As New TextBox()
themeIDField.ID = "theme_id"
themeNamePlaceholder.Controls.Add(themeIDField)
End sub
....and call this at page_load. I now need to get the name value pairs
of these fields to submit to a DB procedure. I've tried using
|
by: magmike |
last post by:
Looking to do sort of the same thing you see on websites, but on
access form, where when a value is selected from a drop down list, if
it matches the desired value, certain form fields appear.
For example, the records in my table are one of three types of
records, Owner, Member or Independent. I have fields in the table that
only correspond to Owner records and only want those fields showing on
the form if the CompanyType is selected as...
|
by: AR123 |
last post by:
Hi
I have set up mandatory form fields but it dosne t seem to be working. Would appreciate it if somone could have a look.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Proforma</title>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
|
by: ERobishaw |
last post by:
Using Winform app writing a HTTP Post using the following... on the
server side, I get no form fields. Request.Form.AllKeys.Length = 0.
If I put the field/value paris in the URL I can use
Request to retrieve the values,
but POST doesn't work.
There is NO Proxy... the only thing I can think is that ASP.NET is
somehow filtering out the page because I'm obviously not posting the
viewstate??? Seems like there was some setting for this,...
|
by: =?Utf-8?B?YnJ1Y2UgYmFya2Vy?= |
last post by:
asp.net munges the name, because this is what the browser posts. remember
forms can not be nested, so the placeholder must be outside the form.
you could create you own naming container, that did not munge the names or
better yet create a pay pal control, that render the form and the hidden
fields.
pretty trival:
public class paypal : WebControl
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |