Writing Code

  • Thread starter Thread starter T Martin
  • Start date Start date
T

T Martin

I am fairly new at writing in VBA. I've picked up a lot of the basics
(docmd.[cmd], recordsets, synchronizing forms, etc) Anyways, sometimes when
I am adding or editing code on some forms or modules, the text I type
automactically turns red like there's an error in the code (and I haven't
even finished typing the command. When I try to put a space in a line of
code (i.e. "docmd.openform "frmName") the space is taken away. I end up
having to type an entire line of code bunched together and then go back and
put the spaces where they are suppose to go.

Does anyone know why this happens and how I can stop this from happening?

thanks in advance for all your help.

T Martin
 
Some weird things can happen in the code editor if you have a form open in
form view with code in its Timer event while you edit code. If you think
that might be the problem, try switching the form to design view before
beginning to edit code.
 
I don't think I had any forms with timer open when editing code, but I
probably did have a form or two open in form mode when editing some code in
a different form. Do you think this may have caused the problem? Do I need
to make sure that every time I edit code, I don't have anything open in form
view? I am going to try that and see if I have any more problems.

thanks for your advice.

T Martin

Brendan Reynolds said:
Some weird things can happen in the code editor if you have a form open in
form view with code in its Timer event while you edit code. If you think
that might be the problem, try switching the form to design view before
beginning to edit code.

--
Brendan Reynolds (MVP)

T Martin said:
I am fairly new at writing in VBA. I've picked up a lot of the basics
(docmd.[cmd], recordsets, synchronizing forms, etc) Anyways, sometimes
when
I am adding or editing code on some forms or modules, the text I type
automactically turns red like there's an error in the code (and I haven't
even finished typing the command. When I try to put a space in a line of
code (i.e. "docmd.openform "frmName") the space is taken away. I end up
having to type an entire line of code bunched together and then go back
and
put the spaces where they are suppose to go.

Does anyone know why this happens and how I can stop this from happening?

thanks in advance for all your help.

T Martin
 
I have heard some reports that not having forms open in form view while
editing code does help to avoid corruption, so it is probably a good idea.
However the particular problem that I thought you might be experiencing
does, as far as I am aware, depend on the form having code running in the
Timer event procedure. If you don't have any code in that procedure, I think
it must be a different problem, but I'm not sure what. Unless someone else
has another suggestion, all I can suggest is to post back if it happens
again, with any additional information that you think may be relevant at the
time.

--
Brendan Reynolds (MVP)

T Martin said:
I don't think I had any forms with timer open when editing code, but I
probably did have a form or two open in form mode when editing some code
in
a different form. Do you think this may have caused the problem? Do I
need
to make sure that every time I edit code, I don't have anything open in
form
view? I am going to try that and see if I have any more problems.

thanks for your advice.

T Martin

Brendan Reynolds said:
Some weird things can happen in the code editor if you have a form open
in
form view with code in its Timer event while you edit code. If you think
that might be the problem, try switching the form to design view before
beginning to edit code.

--
Brendan Reynolds (MVP)

T Martin said:
I am fairly new at writing in VBA. I've picked up a lot of the basics
(docmd.[cmd], recordsets, synchronizing forms, etc) Anyways, sometimes
when
I am adding or editing code on some forms or modules, the text I type
automactically turns red like there's an error in the code (and I haven't
even finished typing the command. When I try to put a space in a line of
code (i.e. "docmd.openform "frmName") the space is taken away. I end
up
having to type an entire line of code bunched together and then go back
and
put the spaces where they are suppose to go.

Does anyone know why this happens and how I can stop this from happening?

thanks in advance for all your help.

T Martin
 
Making sure nothing is open in form view seemed to work. There may have
been a form that had a timer event on somewhere, but it was set at 0, but
I'm not sure that it was open. Oh well, it's working.

Brendan Reynolds said:
I have heard some reports that not having forms open in form view while
editing code does help to avoid corruption, so it is probably a good idea.
However the particular problem that I thought you might be experiencing
does, as far as I am aware, depend on the form having code running in the
Timer event procedure. If you don't have any code in that procedure, I think
it must be a different problem, but I'm not sure what. Unless someone else
has another suggestion, all I can suggest is to post back if it happens
again, with any additional information that you think may be relevant at the
time.

--
Brendan Reynolds (MVP)

T Martin said:
I don't think I had any forms with timer open when editing code, but I
probably did have a form or two open in form mode when editing some code
in
a different form. Do you think this may have caused the problem? Do I
need
to make sure that every time I edit code, I don't have anything open in
form
view? I am going to try that and see if I have any more problems.

thanks for your advice.

T Martin

Brendan Reynolds said:
Some weird things can happen in the code editor if you have a form open
in
form view with code in its Timer event while you edit code. If you think
that might be the problem, try switching the form to design view before
beginning to edit code.

--
Brendan Reynolds (MVP)

I am fairly new at writing in VBA. I've picked up a lot of the basics
(docmd.[cmd], recordsets, synchronizing forms, etc) Anyways, sometimes
when
I am adding or editing code on some forms or modules, the text I type
automactically turns red like there's an error in the code (and I haven't
even finished typing the command. When I try to put a space in a
line
of
code (i.e. "docmd.openform "frmName") the space is taken away. I end
up
having to type an entire line of code bunched together and then go back
and
put the spaces where they are suppose to go.

Does anyone know why this happens and how I can stop this from happening?

thanks in advance for all your help.

T Martin
 
Back
Top