A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Dave Ashish method of updating from previous record



 
 
Thread Tools Display Modes
  #1  
Old April 29th, 2010, 08:53 PM posted to microsoft.public.access.queries
leo
external usenet poster
 
Posts: 236
Default Dave Ashish method of updating from previous record

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong? The = sign is assigned automatically by Access.
I even tried enclosing the whole equation in parenthesis.

Any help will be aprreciated.
Thanking you in advance
Leo
  #2  
Old April 29th, 2010, 09:10 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Dave Ashish method of updating from previous record

Leo wrote:

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong?



You have mixed up the differences between an **expression**
on a control property and **VBA code** in an event
procedure.

To set a control's DafaultValue property to the value in the
form's first record, use the form's Load event **procedure**
with code like you tried to put in the property:

Const cHeight = """"
Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight

--
Marsh
MVP [MS Access]
  #3  
Old April 29th, 2010, 10:07 PM posted to microsoft.public.access.queries
leo
external usenet poster
 
Posts: 236
Default Dave Ashish method of updating from previous record

But this is what Dave has and it specifies the controls defaualt property
though!

(A) To use the curent control value for new records, you need to assign
it to the defaultvalue of the control. For example something like

'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.DefaultValue = cQuote & me!Control.Value & cQuote
'******** Code End **********


"Marshall Barton" wrote:

Leo wrote:

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong?



You have mixed up the differences between an **expression**
on a control property and **VBA code** in an event
procedure.

To set a control's DafaultValue property to the value in the
form's first record, use the form's Load event **procedure**
with code like you tried to put in the property:

Const cHeight = """"
Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight

--
Marsh
MVP [MS Access]
.

  #4  
Old April 29th, 2010, 10:24 PM posted to microsoft.public.access.queries
leo
external usenet poster
 
Posts: 236
Default Dave Ashish method of updating from previous record

Also I made it work by inserting in the afterupdate event of the control. But
it then updates gobally and not seem to be patient specific. I need to update
automatically when a new form is opened on the same patient.

Thanks

"Leo" wrote:

But this is what Dave has and it specifies the controls defaualt property
though!

(A) To use the curent control value for new records, you need to assign
it to the defaultvalue of the control. For example something like

'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.DefaultValue = cQuote & me!Control.Value & cQuote
'******** Code End **********


"Marshall Barton" wrote:

Leo wrote:

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong?



You have mixed up the differences between an **expression**
on a control property and **VBA code** in an event
procedure.

To set a control's DafaultValue property to the value in the
form's first record, use the form's Load event **procedure**
with code like you tried to put in the property:

Const cHeight = """"
Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight

--
Marsh
MVP [MS Access]
.

  #5  
Old April 29th, 2010, 10:42 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Dave Ashish method of updating from previous record

Exactly!

The problem is that you tried to put that VBA code in the
property that the code is trying to set. You seem to have
misunderstood the difference between VBA code and an
expression. You said that you used the expression builder
to create those VBA statements, but I don't see how that can
be possible. Maybe you took a wrong turn somewhere and used
the code builder and somehow stuffed the code into the
property? I think it more likely that the wrong turn was
when you just typed Dave's VBA code directly into the
property.

Regardless of all that, the DefaultValue property expects an
expression (indicated by the = sign). You are NOT doing
that. You should be using the VBA code statements to create
the expression (which doesn't really require the = sign) and
push it into the DefaultValue property.

If you want to set the default value whenever a user
manually sets the property, then put the VBA code in the
control's AfterUpdate event (not the form's Load event).

If you do not understand the distinction I am trying to
explain, then just try what Dave and I are both saying,
instead persisting with your misinterpretation of what he
said.
--
Marsh
MVP [MS Access]


Leo wrote:
But this is what Dave has and it specifies the controls defaualt property
though!

(A) To use the curent control value for new records, you need to assign
it to the defaultvalue of the control. For example something like

'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.DefaultValue = cQuote & me!Control.Value & cQuote
'******** Code End **********


"Marshall Barton" wrote:

Leo wrote:

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong?



You have mixed up the differences between an **expression**
on a control property and **VBA code** in an event
procedure.

To set a control's DafaultValue property to the value in the
form's first record, use the form's Load event **procedure**
with code like you tried to put in the property:

Const cHeight = """"
Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight

--
Marsh
MVP [MS Access]
.


  #6  
Old April 29th, 2010, 11:43 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Dave Ashish method of updating from previous record

Leo wrote:
Also I made it work by inserting in the afterupdate event of the control. But
it then updates gobally and not seem to be patient specific. I need to update
automatically when a new form is opened on the same patient.



That's where you should put it **IF** you want to set the
default when a user enters the patient's height and you want
to use that for any NEW records. If you want to set it to
the value in the form's first record when the form opens,
then use the form's Load event. Possibly, you want to do
both.

"It updates globally" is probably because you set the
control's Value instead of its DefaultValue.

Remember that a DefaultValue is only used when a new record
is started. It should have no effect on existing records.

--
Marsh
MVP [MS Access]
  #7  
Old April 29th, 2010, 11:44 PM posted to microsoft.public.access.queries
leo
external usenet poster
 
Posts: 236
Default Dave Ashish method of updating from previous record

Marshall, I did understand that and has recovered from it. Now the problem I
need to solve is this.

I don't want to set the default value globally so that when a user enters
the value that value is carried to all the individuals. I need it to be
specific for that individual so that anytime a form is open for that
individual his/her values are automatically updated from the last entry. It
should also not change the values of that individual's prior records. Each
individual will have one record for each month. (Each individual also has an
Id number that is being automatically inserted into this form since it is a
subform). Any way this could be accomplished.

Thanking you
Leo

"Marshall Barton" wrote:

Exactly!

The problem is that you tried to put that VBA code in the
property that the code is trying to set. You seem to have
misunderstood the difference between VBA code and an
expression. You said that you used the expression builder
to create those VBA statements, but I don't see how that can
be possible. Maybe you took a wrong turn somewhere and used
the code builder and somehow stuffed the code into the
property? I think it more likely that the wrong turn was
when you just typed Dave's VBA code directly into the
property.

Regardless of all that, the DefaultValue property expects an
expression (indicated by the = sign). You are NOT doing
that. You should be using the VBA code statements to create
the expression (which doesn't really require the = sign) and
push it into the DefaultValue property.

If you want to set the default value whenever a user
manually sets the property, then put the VBA code in the
control's AfterUpdate event (not the form's Load event).

If you do not understand the distinction I am trying to
explain, then just try what Dave and I are both saying,
instead persisting with your misinterpretation of what he
said.
--
Marsh
MVP [MS Access]


Leo wrote:
But this is what Dave has and it specifies the controls defaualt property
though!

(A) To use the curent control value for new records, you need to assign
it to the defaultvalue of the control. For example something like

'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.DefaultValue = cQuote & me!Control.Value & cQuote
'******** Code End **********


"Marshall Barton" wrote:

Leo wrote:

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong?


You have mixed up the differences between an **expression**
on a control property and **VBA code** in an event
procedure.

To set a control's DafaultValue property to the value in the
form's first record, use the form's Load event **procedure**
with code like you tried to put in the property:

Const cHeight = """"
Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight

--
Marsh
MVP [MS Access]
.


.

  #8  
Old April 30th, 2010, 12:13 AM posted to microsoft.public.access.queries
leo
external usenet poster
 
Posts: 236
Default Dave Ashish method of updating from previous record

Also I have inserted a module from Allan Brown that does what I want to do.
But then it inserts values into every field as it is designed to do. Then I
have to specify which are the fields that I dont want to be updated, and
there are too many of them!

"Leo" wrote:

Marshall, I did understand that and has recovered from it. Now the problem I
need to solve is this.

I don't want to set the default value globally so that when a user enters
the value that value is carried to all the individuals. I need it to be
specific for that individual so that anytime a form is open for that
individual his/her values are automatically updated from the last entry. It
should also not change the values of that individual's prior records. Each
individual will have one record for each month. (Each individual also has an
Id number that is being automatically inserted into this form since it is a
subform). Any way this could be accomplished.

Thanking you
Leo

"Marshall Barton" wrote:

Exactly!

The problem is that you tried to put that VBA code in the
property that the code is trying to set. You seem to have
misunderstood the difference between VBA code and an
expression. You said that you used the expression builder
to create those VBA statements, but I don't see how that can
be possible. Maybe you took a wrong turn somewhere and used
the code builder and somehow stuffed the code into the
property? I think it more likely that the wrong turn was
when you just typed Dave's VBA code directly into the
property.

Regardless of all that, the DefaultValue property expects an
expression (indicated by the = sign). You are NOT doing
that. You should be using the VBA code statements to create
the expression (which doesn't really require the = sign) and
push it into the DefaultValue property.

If you want to set the default value whenever a user
manually sets the property, then put the VBA code in the
control's AfterUpdate event (not the form's Load event).

If you do not understand the distinction I am trying to
explain, then just try what Dave and I are both saying,
instead persisting with your misinterpretation of what he
said.
--
Marsh
MVP [MS Access]


Leo wrote:
But this is what Dave has and it specifies the controls defaualt property
though!

(A) To use the curent control value for new records, you need to assign
it to the defaultvalue of the control. For example something like

'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.DefaultValue = cQuote & me!Control.Value & cQuote
'******** Code End **********


"Marshall Barton" wrote:

Leo wrote:

I need to enter the Height of the patient every time the form opens. The
name of the control is [Fld37]. Yes I will name it better next time!

I used Dave Ashish method and entered the expression in the default value of
the control's data. The following is the expression it created after I typed
in the code in the expression builder (the only option it will give me).

= const cHeight=""""
me![Fld37].defaultValue=cHeight&me![Fld37].Value&cHeight

It is not working and flashes the following error message:

You might have entered an operand without an operator

What am I doing wrong?


You have mixed up the differences between an **expression**
on a control property and **VBA code** in an event
procedure.

To set a control's DafaultValue property to the value in the
form's first record, use the form's Load event **procedure**
with code like you tried to put in the property:

Const cHeight = """"
Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight

--
Marsh
MVP [MS Access]
.


.

  #9  
Old April 30th, 2010, 04:42 AM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Dave Ashish method of updating from previous record

Leo wrote:

Marshall, I did understand that and has recovered from it. Now the problem I
need to solve is this.

I don't want to set the default value globally so that when a user enters
the value that value is carried to all the individuals. I need it to be
specific for that individual so that anytime a form is open for that
individual his/her values are automatically updated from the last entry. It
should also not change the values of that individual's prior records. Each
individual will have one record for each month. (Each individual also has an
Id number that is being automatically inserted into this form since it is a
subform). Any way this could be accomplished.



Well, there usually is a way to all kinds of things, but
some things are more complex than others. Because
DefaultValue is a property of the text box, it has no
connection to some other information in other records (ie.
the individual)

That means you would have to create a way to determine the
individual and the default height you want to use for the
individual. I think that can be done by having a table with
one record per individual and adding a field for the default
height. Then you could use the form's Current event to
retrieve the default height field from that table and stuff
that into the text box's DefaultValue property. With the
default height in that kind of table, it would probably be
easier to join that table to the table you have now to make
the default height a field in the form's record source
query.

At his point I am not convinced that the DefaultValue
property is really helping here. You could just use the
form's BeforeInsert event to retrieve the value and stuff it
directly into the value property when a new record is being
created. OTOH, considering how new you are to all this, you
may want to put a hold on this particular goal until you
have a firm grasp on using VBA code.

--
Marsh
MVP [MS Access]
  #10  
Old April 30th, 2010, 04:46 AM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Dave Ashish method of updating from previous record

Leo wrote:

Also I have inserted a module from Allan Brown that does what I want to do.
But then it inserts values into every field as it is designed to do. Then I
have to specify which are the fields that I dont want to be updated, and
there are too many of them!



Sorry, I have no idea what you are referring to here.

Generally, you can modify the code to use just the fields
you want or play a few other tricks to identify which fields
should be set an which ones should be ignored.

--
Marsh
MVP [MS Access]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:46 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.