Go Back   Access World Forums > Microsoft Access Discussion > Tables

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-07-2019, 04:16 PM   #1
InFlight
User
 
Join Date: Jun 2015
Location: Masterton, New Zealand
Posts: 99
Thanks: 34
Thanked 0 Times in 0 Posts
InFlight is on a distinguished road
Cool Required.Value

I am using VBA to change [myTableName]![myFieldName]!Required.Value = -1
I am getting error
Error 2465 Can't find field '|1' referred to in your expression

InFlight is offline   Reply With Quote
Old 08-07-2019, 04:20 PM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,964
Thanks: 13
Thanked 4,055 Times in 3,991 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Required.Value

What is your actual code? You can't just refer to a table like that.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 08-07-2019, 04:24 PM   #3
InFlight
User
 
Join Date: Jun 2015
Location: Masterton, New Zealand
Posts: 99
Thanks: 34
Thanked 0 Times in 0 Posts
InFlight is on a distinguished road
Re: Required.Value

Hi
I think i may have got it by trial and error
Is this correct
Code:
    DoCmd.SetWarnings False
    db.TableDefs("Patronage").Fields("PatronageId").Required = True
    DoCmd.SetWarnings True

InFlight is offline   Reply With Quote
Old 08-07-2019, 04:35 PM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,964
Thanks: 13
Thanked 4,055 Times in 3,991 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Required.Value

If it works, it's correct.

You haven't declared or set the db variable. You can probably use CurrentDb instead, and you don't need the SetWarnings lines (I don't think anyway).
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 08-07-2019, 06:58 PM   #5
InFlight
User
 
Join Date: Jun 2015
Location: Masterton, New Zealand
Posts: 99
Thanks: 34
Thanked 0 Times in 0 Posts
InFlight is on a distinguished road
Re: Required.Value

Sorry about that. It is set earlier
InFlight is offline   Reply With Quote
Old 08-07-2019, 07:16 PM   #6
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,964
Thanks: 13
Thanked 4,055 Times in 3,991 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Required.Value

So did it work?

Say hi to my daughter!
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
InFlight (08-07-2019)
Old 08-07-2019, 07:20 PM   #7
InFlight
User
 
Join Date: Jun 2015
Location: Masterton, New Zealand
Posts: 99
Thanks: 34
Thanked 0 Times in 0 Posts
InFlight is on a distinguished road
Re: Required.Value

Yes it did.Thanks
I am still learning.

Cheers

InFlight is offline   Reply With Quote
Old 08-07-2019, 07:22 PM   #8
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,964
Thanks: 13
Thanked 4,055 Times in 3,991 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Required.Value

No problem.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 08-08-2019, 10:03 PM   #9
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,808
Thanks: 13
Thanked 1,510 Times in 1,436 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Required.Value

Quote:
DoCmd.SetWarnings False
db.TableDefs("Patronage").Fields("PatronageId").Re quired = True
DoCmd.SetWarnings True
I'm not sure what this might be doing but it isn't an update query. Are you trying to set the required property of a field to true?
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 08-09-2019, 06:25 AM   #10
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,964
Thanks: 13
Thanked 4,055 Times in 3,991 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Required.Value

It does set the required property to true, yes.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 08-09-2019, 07:28 AM   #11
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,808
Thanks: 13
Thanked 1,510 Times in 1,436 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Required.Value

It was the .Value reference that confused me.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 08-09-2019, 07:33 AM   #12
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,964
Thanks: 13
Thanked 4,055 Times in 3,991 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Required.Value

Post 3 didn't clarify it?
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 08-11-2019, 10:45 PM   #13
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 1,945
Thanks: 19
Thanked 370 Times in 363 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Required.Value

Odd question, why are you setting it as required at the table level by code instead of simply updating the table definition?
Mark_ is offline   Reply With Quote
Old 08-12-2019, 03:03 AM   #14
InFlight
User
 
Join Date: Jun 2015
Location: Masterton, New Zealand
Posts: 99
Thanks: 34
Thanked 0 Times in 0 Posts
InFlight is on a distinguished road
Re: Required.Value

not to me.

InFlight is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Required Fields to Forms and can i change required field Validation Text EmergentGuru Forms 14 09-16-2016 02:33 PM
Fields are required to be filled out even though not set as required oliwia Forms 3 11-03-2014 10:17 PM
Display required data in subform help required please TIDMAN General 6 02-27-2011 12:41 AM
Gray Out/Not required or Not Grayed Out/Required depending on value in listbox joe789 Forms 1 05-10-2004 08:16 AM
Required fields, "PLEASE ENTER IN THIS FIELD", IT IS REQUIRED. HELP PLEASE jenny23 Forms 6 04-28-2004 11:36 AM




All times are GMT -8. The time now is 02:59 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World