473,386 Members | 2,114 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,386 software developers and data experts.

VBA Error "The Value you entered isn't valid for this Field"

Build an input Form that a user can use to query info Edit and or Update data.

The Form has unbound txt and cbo fields that is linked to a subform. The form also has a Query, Edit, Update, Clear Button

Query Button Code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdbtnQuery_Click()
  2. me.subformSupplyRqmtsUpdate.Requery
Edit Button Code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdbtnEdit_Click()
  2. If Not (Me.subformSupplyRqmtsUpdate.Form.Recordset.EOF and Me.subformSupplyRqmtsUpdate.Form.Recordset.BOF) Then
  3. With Me.txtSupplyRqmtsID = .Fields("SupplyRqmtsID")
  4. Me.cboUsingLoc = .Fields("UsingLoc")
  5. Me.txtFicalYear = .Fields("FiscalYear")
  6. Me.txtState = .Fields("State")
  7. 'store id of Supply Rqmts in Tag of txtSupplyRqmtsId in case ID is modified
  8. Me.txtSupplyRqmtsID.Tag = .Fields("SupplyRqmtsID")
Update Button Code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdbtnEdit_Click()
  2. CurrentDb.Execute "UPDATE tblSupplyItemRequirement " & _
  3. " SET FiscalYear=" & Me.txtFiscalYear & _
  4. ", UsingLoc='" & Me.cboUsingLoc & "'" & _
  5. ", State='" & me.txtState & "'" & _
  6. "WHERE SupplyRqmtsID=" & Me.txtWrmRqmtsID.Tag
Clear Button Code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdbtnEdit_Click()
  2. When Button is clicked clears all the fields on the main form to Reset the form to query or Add
  3. Me.txtWrmRqmtsID.Tag = Null
  4. Me.txtFiscalYear = Null
  5. Me.cboUsingLoc = Null
  6. Me.txtState = Null
Everything works when you first open the form, however; when you query a record and edit/update the record and then you hit the clear button to reset the form to query another record. When hit the edit button on the new info that was queried I get the following error

"The Value you entered isn't valid for this field"

when I hit debug it highlights

With Me.txtSupplyRqmtsID = .Fields("SupplyRqmtsID")

From the Edit Command VBA code

What do I need to do to fix this issue so I do not have to close out the form to query and edit another record.

Thanks
Dec 19 '16 #1
2 2687
MikeTheBike
639 Expert 512MB
Hi

A Field returned by the form query that does not have a bound control cannot be referenced like this
Expand|Select|Wrap|Line Numbers
  1.  .Fields("SupplyRqmtsID")
Fields is not a valid property or method of a form. It is a property of a recordset.

There are a number of ways that such a field can be referenced :-

Expand|Select|Wrap|Line Numbers
  1. MsgBox Me.Recordset("SupplyRqmtsID")
  2. MsgBox Me.Recordset.Fields("SupplyRqmtsID")
or even
Expand|Select|Wrap|Line Numbers
  1. MsgBox [SupplyRqmtsID]
All should give the same result (provided it is not null, which will result in an error message!).

You can also used the forms RecordsetClone object in place of the Recordset object.

This, obviously, will apply to all the other such references in this Sub

I also think the With without an End With may cause an issue!?

Having said all that the error message I get is
'Invalid or unqualified reference' (A2007)

So this may be a different issue??


HTH


MTB
Dec 20 '16 #2
I am a Database developer from Darae suf ,Afghanistan.

well this error is happening that a form field cannot be referenced to a textbox like you did. you can do it as below

yours one :With Me.txtSupplyRqmtsID = .Fields("SupplyRqmtsID"

change it like this :

With Me.txtSupplyRqmtsID.form.recordset

Me.Schooltxt = Forms![<<if you have main form >>]![txtSupplyRqmtsID].form![SupplyRqmtsID]

i have already tested this
Good luck

Cennamanesh
Apr 26 '17 #3

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

Similar topics

0
by: Omavlana | last post by:
Hi, I am getting the above error "specified cast is not valid" while sending the parameter to crystal report through VB.NET. Here is my code.. '*********** Dim paramFields As New...
0
by: yelena | last post by:
Hello, We need to use version php-4.4.0-Win32 because one of the portal software doesn't support version php-5.0.5-Win32. We cannot get the PHP setup part working. Here is the error message: ...
1
by: Glen Welsh via AccessMonster.com | last post by:
I am trying to set a control to equal the last value entered for that control on the previous form. In other words: I have a control called HullNumber, which will remain constant for approximately...
10
by: MLH | last post by:
Would like to examine the value entered into a textbox on an A97 form during the BeforeUpdate event. The textbox may or may not have had an earlier entry in it prior to the latest value that is...
6
by: MLH | last post by:
Using A97. Want to examine 17-char VIN entered by user. VIN codes are alphanumeric and do not contain Oh's to prevent the confusion that could result if zeros were misread as O's or o's. So, if...
0
by: Subhankar | last post by:
Hi, I am trying to open a MS Project residing in a MS SQL Server. I have the following code for the FileOpen: projectApp.FileOpen("<ChouOister>\\Test Project 2", false, 0, null, null, null,...
0
by: =?Utf-8?B?Y2NfY3Jhc2g=?= | last post by:
Hello all, This is probably a simple issue but since I am a newbie I am really stuck on it. I have been developing some code and I was using rowPosition to pull data from a Access Data base and...
2
by: metalheadstorm | last post by:
Ok this is my first post, gtz me ^^ well i have a DB im making for a project and im using a Vb interface and a access db linking them togethering using ADO. on one SStab / form i have a...
2
by: Emily Lisker | last post by:
I am using Yes/No/Null number combo boxes per Allen Browne's instructions (http://allenbrowne.com/NoYesNo.html). My validation rule is: "Is Null Or 0 Or -1" I copied Allen Browne's lookup box...
7
by: Nick Ferreira | last post by:
How do you update value "Units available" on Table STOCK ON HAND from a value entered on a form for attribute "Units In" on table UNITS IN. I need to update the "Units available" as soon as control...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.