Visual basic help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two date fields, and as the first one is filled in, i want the second
to add 30 month calculation and post it to the second field. This is what I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)
 
Hey Susan,

Thanks for the help; however, I get this error

Microsoft Office Access can't find the macro 'DateAdd("m",30,([Main
Roster]![Active_Initial_106_2_Qual]Me.'

can you help?
SusanV said:
Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


JudyT said:
I have two date fields, and as the first one is filled in, i want the
second
to add 30 month calculation and post it to the second field. This is what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Susan Sorry, the statement is this...can't find the macro 'Me.'

SusanV said:
Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


JudyT said:
I have two date fields, and as the first one is filled in, i want the
second
to add 30 month calculation and post it to the second field. This is what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Where is the code that's running: in a stand-alone module, or in a module
associated with a form (which is actually a class)?

"Me." is a keyword that identifies the specific instance of the class where
the code is executing. In this particular context, the expectation is that
it's in the module associated with a form, and that FirstField and
SecondField are controls on that form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Susan Sorry, the statement is this...can't find the macro 'Me.'

SusanV said:
Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


JudyT said:
I have two date fields, and as the first one is filled in, i want the
second
to add 30 month calculation and post it to the second field. This is what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Douglas,
I am new to access....now with that said, I made a form from a query, which
comes from a table. The VB code that I used was from the form, then the
event procedure, then i copy and pasted the vb code here. So I am not sure
what you are talking about, would you mind explaning further? Thank you
JudyT

Douglas J Steele said:
Where is the code that's running: in a stand-alone module, or in a module
associated with a form (which is actually a class)?

"Me." is a keyword that identifies the specific instance of the class where
the code is executing. In this particular context, the expectation is that
it's in the module associated with a form, and that FirstField and
SecondField are controls on that form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Susan Sorry, the statement is this...can't find the macro 'Me.'

SusanV said:
Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


I have two date fields, and as the first one is filled in, i want the
second
to add 30 month calculation and post it to the second field. This is what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
That's where the code should be, so there's something else going on that's
causing the problem with Me.

One thing you might check is whether you have a problem with the References
collection.

While you're in the VB Editor, select Tools | References from the menu bar.
Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JudyT said:
Douglas,
I am new to access....now with that said, I made a form from a query,
which
comes from a table. The VB code that I used was from the form, then the
event procedure, then i copy and pasted the vb code here. So I am not
sure
what you are talking about, would you mind explaning further? Thank you
JudyT

Douglas J Steele said:
Where is the code that's running: in a stand-alone module, or in a module
associated with a form (which is actually a class)?

"Me." is a keyword that identifies the specific instance of the class
where
the code is executing. In this particular context, the expectation is
that
it's in the module associated with a form, and that FirstField and
SecondField are controls on that form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Susan Sorry, the statement is this...can't find the macro 'Me.'

:

Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


I have two date fields, and as the first one is filled in, i want
the
second
to add 30 month calculation and post it to the second field. This
is what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Hey Douglas,

Okay, I went into the references as you suggested and unselected them;
however, when I went back in to reselect...one is missing! It is Microsoft
Office SP Web Components. Why is it not there and where can i get it? I am
assuming that I need it because I have webpages associated for reports.
Help! please....

Douglas J. Steele said:
That's where the code should be, so there's something else going on that's
causing the problem with Me.

One thing you might check is whether you have a problem with the References
collection.

While you're in the VB Editor, select Tools | References from the menu bar.
Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JudyT said:
Douglas,
I am new to access....now with that said, I made a form from a query,
which
comes from a table. The VB code that I used was from the form, then the
event procedure, then i copy and pasted the vb code here. So I am not
sure
what you are talking about, would you mind explaning further? Thank you
JudyT

Douglas J Steele said:
Where is the code that's running: in a stand-alone module, or in a module
associated with a form (which is actually a class)?

"Me." is a keyword that identifies the specific instance of the class
where
the code is executing. In this particular context, the expectation is
that
it's in the module associated with a form, and that FirstField and
SecondField are controls on that form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susan Sorry, the statement is this...can't find the macro 'Me.'

:

Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


I have two date fields, and as the first one is filled in, i want
the
second
to add 30 month calculation and post it to the second field. This
is
what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
http://www.microsoft.com/downloads/...59-0A86-4FB2-A7EE-5F3A499515DD&displaylang=EN

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Hey Douglas,

Okay, I went into the references as you suggested and unselected them;
however, when I went back in to reselect...one is missing! It is Microsoft
Office SP Web Components. Why is it not there and where can i get it? I am
assuming that I need it because I have webpages associated for reports.
Help! please....

Douglas J. Steele said:
That's where the code should be, so there's something else going on that's
causing the problem with Me.

One thing you might check is whether you have a problem with the References
collection.

While you're in the VB Editor, select Tools | References from the menu bar.
Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JudyT said:
Douglas,
I am new to access....now with that said, I made a form from a query,
which
comes from a table. The VB code that I used was from the form, then the
event procedure, then i copy and pasted the vb code here. So I am not
sure
what you are talking about, would you mind explaning further? Thank you
JudyT

:

Where is the code that's running: in a stand-alone module, or in a module
associated with a form (which is actually a class)?

"Me." is a keyword that identifies the specific instance of the class
where
the code is executing. In this particular context, the expectation is
that
it's in the module associated with a form, and that FirstField and
SecondField are controls on that form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susan Sorry, the statement is this...can't find the macro 'Me.'

:

Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


I have two date fields, and as the first one is filled in, i want
the
second
to add 30 month calculation and post it to the second field. This
is
what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Hey,

I work for a Corporation and I can't download this...what elese can I do.

Douglas J Steele said:
http://www.microsoft.com/downloads/...59-0A86-4FB2-A7EE-5F3A499515DD&displaylang=EN

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Hey Douglas,

Okay, I went into the references as you suggested and unselected them;
however, when I went back in to reselect...one is missing! It is Microsoft
Office SP Web Components. Why is it not there and where can i get it? I am
assuming that I need it because I have webpages associated for reports.
Help! please....

Douglas J. Steele said:
That's where the code should be, so there's something else going on that's
causing the problem with Me.

One thing you might check is whether you have a problem with the References
collection.

While you're in the VB Editor, select Tools | References from the menu bar.
Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Douglas,
I am new to access....now with that said, I made a form from a query,
which
comes from a table. The VB code that I used was from the form, then the
event procedure, then i copy and pasted the vb code here. So I am not
sure
what you are talking about, would you mind explaning further? Thank you
JudyT

:

Where is the code that's running: in a stand-alone module, or in a module
associated with a form (which is actually a class)?

"Me." is a keyword that identifies the specific instance of the class
where
the code is executing. In this particular context, the expectation is
that
it's in the module associated with a form, and that FirstField and
SecondField are controls on that form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susan Sorry, the statement is this...can't find the macro 'Me.'

:

Hi Judy,

In the first field's after update event:

Me.SecondField = DateAdd("m", 30, Me.FirstField)

--
hth,
SusanV


I have two date fields, and as the first one is filled in, i want
the
second
to add 30 month calculation and post it to the second field. This
is
what
I
have thus far:

Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Okay, I have gone off the path of my project.
Is there any other way to do the below visual basic
have two date fields, and as the first one is filled in, i
wantthe >second add 30 month calculation and post it to the second field.
Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
What you've got there isn't valid VBA.

DoCmd isn't a stand-along operator: you must use one of the methods
associated with it.

DateAdd takes 3 operators: you've only got 2 iinside the parentheses.

You're missing a closing square bracket after Current_106_ (and you have one
too many closing parenthesis)

In the AfterUpdate of the first field, put code to assign the value to the
second field:

Me.MySecondField = DateAdd("m", 30, Me.MyFirstField)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Okay, I have gone off the path of my project.
Is there any other way to do the below visual basic
have two date fields, and as the first one is filled in, i
wantthe >second add 30 month calculation and post it to the second field.
Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 
Douglas,

Okay, now I am getting the Me statement again. Am I suppose to write a
macro called me? If so, where would i find something like that?
Thank you for your help!
Judy

Douglas J Steele said:
What you've got there isn't valid VBA.

DoCmd isn't a stand-along operator: you must use one of the methods
associated with it.

DateAdd takes 3 operators: you've only got 2 iinside the parentheses.

You're missing a closing square bracket after Current_106_ (and you have one
too many closing parenthesis)

In the AfterUpdate of the first field, put code to assign the value to the
second field:

Me.MySecondField = DateAdd("m", 30, Me.MyFirstField)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JudyT said:
Okay, I have gone off the path of my project.
Is there any other way to do the below visual basic
have two date fields, and as the first one is filled in, i
wantthe >second add 30 month calculation and post it to the second field.
Private Sub Active_Initial_106_2_Qual_Enter()
DoCmd (DateAdd("m", 30)([Main Roster Database].[Form_Main
Roster]![Current_106_))
End Sub

Thanks for your help in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top