From: Leo on 29 Apr 2010 15:53 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
From: Marshall Barton on 29 Apr 2010 16:10 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]
From: Leo on 29 Apr 2010 17:07 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] > . >
From: Leo on 29 Apr 2010 17:24 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] > > . > >
From: Marshall Barton on 29 Apr 2010 17:42 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] >> . >>
|
Next
|
Last
Pages: 1 2 3 Prev: Need null values for several fields in db Next: Convert to Proper or Title Case in Access 2003 |