VB code help

N

Nick T

Hi,

Iv got various linked tables etc, however the details regarding my database
i dont think are relevant.
Im using the following code in the event of a text box:

Me.Serial_No = !Serial_No

In code form, what do i put in if there is a 'space' in the title of a
tables field name.
For info, Serial No is the name of a field on a table where my db gets info
from.
However this code does work for my fields which do not have spaces in their
names which makes me think its the 'space' issue.
eg:
Me.Date = !Date

I know it would sound simple to change my field headings to omit spaces,
however this is not an option unfortunately.

Any suggestions greatly appreciated.

Nick
 
K

Klatuu

Use brackets to enclose the name:
Me.Serial_No = ![Serial No]

But, the question is Why? Is this not a bound form?
 
N

Nick T

Hi,
Thanks for the info - its worked great.

Its because, i have a form which is controlled by command buttons -
information is taken from a linked excel spreasheet, put into the form which
adds a new record to a second access table. All the relevant 'looked up' data
from the excel sheet goes into the form, a user can add additional
information & then the db stores it all in one access table.
Which leads me onto another question:

i have 3 text boxes - 'Date' 'Time' and 'Date&Time'
Text box 'date' and text box 'time' are automatically updated from the
information which is looked up in my excel sheet. Text box 'Date&Time' is
updated when a user clicks a command button. This basically enables me to
see when a product was made, and when its location was changed. ie. product
made, & 'Date' & 'Time' are updated automatically, then when product is
moved, 'Date&Time' are filled in using a command button. However, there
seems to be some conflict between these text boxes - none are linked to
eachother, however if 'Date' says 22.09.08 and 'time' says 10:35, my command
button which is clicked should put the current date & time into 'Date&Time'
text box, however when this is clicked, the same date & time which appears in
'Date' and 'Time' is entered ie. 22.09.08 10:33
Whereas i want the actual time of which the command button is clicked to be
entered.

Hope i didnt loose you with all that!
Any suggestions appreciated.

Many thanks
Nick



Klatuu said:
Use brackets to enclose the name:
Me.Serial_No = ![Serial No]

But, the question is Why? Is this not a bound form?

Nick T said:
Hi,

Iv got various linked tables etc, however the details regarding my
database
i dont think are relevant.
Im using the following code in the event of a text box:

Me.Serial_No = !Serial_No

In code form, what do i put in if there is a 'space' in the title of a
tables field name.
For info, Serial No is the name of a field on a table where my db gets
info
from.
However this code does work for my fields which do not have spaces in
their
names which makes me think its the 'space' issue.
eg:
Me.Date = !Date

I know it would sound simple to change my field headings to omit spaces,
however this is not an option unfortunately.

Any suggestions greatly appreciated.

Nick
 
K

Klatuu

First, rename things. You are using Date and Time which are both reserverd
words and should not be used as Access Names. The & will also likely cause
a problem because it is a concatenation character. If you can't change the
names, at least put them in brackets as welll. That will keep from
confusing Access most of the time.

As to your actual question, if you want to store the date and time the
button was clicked, put this in the button's Clicke event:

Me.[Date&Time] = Now


Nick T said:
Hi,
Thanks for the info - its worked great.

Its because, i have a form which is controlled by command buttons -
information is taken from a linked excel spreasheet, put into the form
which
adds a new record to a second access table. All the relevant 'looked up'
data
from the excel sheet goes into the form, a user can add additional
information & then the db stores it all in one access table.
Which leads me onto another question:

i have 3 text boxes - 'Date' 'Time' and 'Date&Time'
Text box 'date' and text box 'time' are automatically updated from the
information which is looked up in my excel sheet. Text box 'Date&Time' is
updated when a user clicks a command button. This basically enables me to
see when a product was made, and when its location was changed. ie.
product
made, & 'Date' & 'Time' are updated automatically, then when product is
moved, 'Date&Time' are filled in using a command button. However, there
seems to be some conflict between these text boxes - none are linked to
eachother, however if 'Date' says 22.09.08 and 'time' says 10:35, my
command
button which is clicked should put the current date & time into
'Date&Time'
text box, however when this is clicked, the same date & time which appears
in
'Date' and 'Time' is entered ie. 22.09.08 10:33
Whereas i want the actual time of which the command button is clicked to
be
entered.

Hope i didnt loose you with all that!
Any suggestions appreciated.

Many thanks
Nick



Klatuu said:
Use brackets to enclose the name:
Me.Serial_No = ![Serial No]

But, the question is Why? Is this not a bound form?

Nick T said:
Hi,

Iv got various linked tables etc, however the details regarding my
database
i dont think are relevant.
Im using the following code in the event of a text box:

Me.Serial_No = !Serial_No

In code form, what do i put in if there is a 'space' in the title of a
tables field name.
For info, Serial No is the name of a field on a table where my db gets
info
from.
However this code does work for my fields which do not have spaces in
their
names which makes me think its the 'space' issue.
eg:
Me.Date = !Date

I know it would sound simple to change my field headings to omit
spaces,
however this is not an option unfortunately.

Any suggestions greatly appreciated.

Nick
 
N

Nick T

Thanks soooo much!

Great help!
Nick

Klatuu said:
First, rename things. You are using Date and Time which are both reserverd
words and should not be used as Access Names. The & will also likely cause
a problem because it is a concatenation character. If you can't change the
names, at least put them in brackets as welll. That will keep from
confusing Access most of the time.

As to your actual question, if you want to store the date and time the
button was clicked, put this in the button's Clicke event:

Me.[Date&Time] = Now


Nick T said:
Hi,
Thanks for the info - its worked great.

Its because, i have a form which is controlled by command buttons -
information is taken from a linked excel spreasheet, put into the form
which
adds a new record to a second access table. All the relevant 'looked up'
data
from the excel sheet goes into the form, a user can add additional
information & then the db stores it all in one access table.
Which leads me onto another question:

i have 3 text boxes - 'Date' 'Time' and 'Date&Time'
Text box 'date' and text box 'time' are automatically updated from the
information which is looked up in my excel sheet. Text box 'Date&Time' is
updated when a user clicks a command button. This basically enables me to
see when a product was made, and when its location was changed. ie.
product
made, & 'Date' & 'Time' are updated automatically, then when product is
moved, 'Date&Time' are filled in using a command button. However, there
seems to be some conflict between these text boxes - none are linked to
eachother, however if 'Date' says 22.09.08 and 'time' says 10:35, my
command
button which is clicked should put the current date & time into
'Date&Time'
text box, however when this is clicked, the same date & time which appears
in
'Date' and 'Time' is entered ie. 22.09.08 10:33
Whereas i want the actual time of which the command button is clicked to
be
entered.

Hope i didnt loose you with all that!
Any suggestions appreciated.

Many thanks
Nick



Klatuu said:
Use brackets to enclose the name:
Me.Serial_No = ![Serial No]

But, the question is Why? Is this not a bound form?

Hi,

Iv got various linked tables etc, however the details regarding my
database
i dont think are relevant.
Im using the following code in the event of a text box:

Me.Serial_No = !Serial_No

In code form, what do i put in if there is a 'space' in the title of a
tables field name.
For info, Serial No is the name of a field on a table where my db gets
info
from.
However this code does work for my fields which do not have spaces in
their
names which makes me think its the 'space' issue.
eg:
Me.Date = !Date

I know it would sound simple to change my field headings to omit
spaces,
however this is not an option unfortunately.

Any suggestions greatly appreciated.

Nick
 

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

Similar Threads


Top