473,659 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference Form Fields Value - Application-defined Error 2465

52 New Member
Hello,

I am trying to refer to fields on a given form from the form query's recordset, essentially from the following commands:
Expand|Select|Wrap|Line Numbers
  1.     Dim frm As Form 'Refers to the current form
  2.     Dim tagName As String 'Refers to the field in the form's recordset (not a control on the form)
  3.  
  4.     ...
  5.     frm.Fields(tagName).Value 'This gives Error 2465
  6.  
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:
Expand|Select|Wrap|Line Numbers
  1. 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
  2.     Dim keyName As String, keyValue As Long
  3.     Dim tempRecord As Long
  4.     Dim fld As Field
  5.  
  6. On Error GoTo Err_duplicateRecord
  7.     Set rsExist = CurrentDb.OpenRecordset(tableName)
  8.     keyName = uniqueCtl.ControlSource
  9.     If uniqueCtl.Value > 1 Then
  10.         keyValue = uniqueCtl.Value
  11.         If frm.NewRecord Then
  12.             Call MsgBox("New records cannot be duplicated, please save this record first then try again.", vbExclamation, "Nonexistant Record")
  13.             duplicateRecord = -1
  14.             Exit Function
  15.         ElseIf frm.Dirty Then  
  16.             If MsgBox("Save changes?", vbYesNo, "Unsaved Changes Detected") = vbYes Then
  17.                 MsgBox frm.Fields("LineTag")  
  18.                 If isSaveable(tableName, tagName, frm.Fields(tagName).Value, keyName, keyValue) Then 'This gives Error 2465  
  19.                     Call saveRecord(frm, keyValue)  
  20.                 Else
  21.                     Exit Function
  22.                 End If
  23.             Else
  24.                 Exit Function
  25.             End If
  26.         End If
  27.     ...
  28. End Function
  29.  
Oct 29 '10 #1
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:
Expand|Select|Wrap|Line Numbers
  1. Dim rst As DAO.Recordset
  2. Dim fld As DAO.Field
  3.  
  4. Set rst = Me.RecordsetClone
  5.  
  6. For Each fld In rst.Fields
  7.   Debug.Print fld.Name
  8. Next
Sample Output:
Expand|Select|Wrap|Line Numbers
  1. EmployeeID
  2. LastName
  3. FirstName
  4. MI
  5. Title
  6. TitleOfCourtesy
  7. BirthDate
  8. HireDate
  9. Address
  10. City
  11. Region
  12. PostalCode
  13. Country
  14. HomePhone
  15. Extension
  16. Photo
  17. Notes
  18. ReportsTo
To actually refer to Fields within the context of a Form's Recordset, once it has been defined:
Expand|Select|Wrap|Line Numbers
  1. rst!EmployeeID
  2. rst!LastName
  3. rst!FirstName
  4. rst!MI
  5. rst!Title
  6. rst!TitleOfCourtesy
  7. rst!BirthDate
  8. rst!HireDate
  9. rst!Address
  10. rst!City
  11. rst!Region
  12. rst!PostalCode
  13. rst!Country
  14. rst!HomePhone
  15. rst!Extension
  16. rst!Photo
  17. rst!Notes
  18. rst!ReportsTo
Oct 29 '10 #2
jbrumbau
52 New Member
Just figured it out, I used:
frm.RecordSet.Fields(tagName )

Thanks for help ADezii, Me.RecordsetClo ne was a good hint.
Oct 29 '10 #3
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.
Oct 29 '10 #4

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

Similar topics

4
2631
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.
4
9899
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...
3
2924
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!
7
3802
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...
7
14153
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
3
5840
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
1
19073
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...
1
1543
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">
1
3685
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,...
0
899
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
0
8428
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
8335
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,...
0
8747
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
7356
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...
0
5649
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
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
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
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
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.