button that locks fields

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

Guest

I have created a small call logging database on access. i want to create a
button that when pressed will lock all of the information in the feilds. I am
very new to this so any help would be great.
 
In the Click Event of the command button:

With Me
.AllowEdits = False
.AllowDeletions = False
End With

The other thing will be to allow them back on. You could either use toggle
buttons in an option group to turn it on and off or you can put the same code
in the Form Current event except replace False with True. With this method,
whenever you move to a different or new record, editing will be allowed
again until the button is clicked.
 
Many Many thanks for that.

Just a couple of other questions.

1, In a date field, is there a way of auto inserting the date?

2, Also Is there a way of changing the number that a auto number starts from?

3, And on a final note now i have locked out the fields information, is
there a way of turning the feild boxes grey for example?

Many thanks again
 
--
Dave Hargis, Microsoft Access MVP


Darren said:
Many Many thanks for that.

Just a couple of other questions.

1, In a date field, is there a way of auto inserting the date?
First order of business. Forms do not have fields. Tables and queries have
fields. Forms have controls and some of those controls can be bound to
fields in the form's record source. But the short answer is if you want the
date to be today's date, put Date() in the control's Default Value property.
When you create a new record, it will automatically populate the control with
the date.
2, Also Is there a way of changing the number that a auto number starts from?
It is possible, but by asking the question, I know you are not using an
autonumber field correctly. You should not care about the value of an
autonumber and users should never see it. Autonumber field are just a tool
for creating unique value to be used as primary keys and relating tables. If
you are using it for something else, post back with what you want to do and
we can help find a better approach.
3, And on a final note now i have locked out the fields information, is
there a way of turning the feild boxes grey for example?

Yes, but it take a lot more code because you have to go through the controls
collection of the form and set each editable control's Enabled property to
False.
 
Ok thanks for the advice Not to worry about the grey boxes. I want this to be
as simpleas possible.

with regards to auto number issue. I need to have a new number allocated to
each new call that is inputed. I have all the other boxes for the relevant
info to be stored, and have even created a button that will create a new
feild in the form. I need the number to be used only once and to start at
whaterver number i like. Can you sugest anything.

Also the date has worked fine except it comes out at 1428??? Any help would
be great.
 
--
Dave Hargis, Microsoft Access MVP


Darren said:
Ok thanks for the advice Not to worry about the grey boxes. I want this to be
as simpleas possible.

with regards to auto number issue. I need to have a new number allocated to
each new call that is inputed. I have all the other boxes for the relevant
info to be stored, and have even created a button that will create a new
feild in the form. I need the number to be used only once and to start at
whaterver number i like. Can you sugest anything.

You can create a fake autonumber. Each time you add a new record you can
determine the highest number currently in the field and add 1 to it. This
you do in the form's current event. You only do it for new records:

If Me.NewRecord Then
Me.txtCallNumber = Nz(DLookup("[CallNumber]", "CallTable"),0) + 1
End If

If you want to start at a specific number, put a record in the table with
the number you want to start with - 1 (I think), because the next new record
will be one higher than the value in the record you start with.
Also the date has worked fine except it comes out at 1428??? Any help would
be great.

Is the table field a date data type? Are you using any formatting on the
control?
 
I think i will leave the number issue for the moment. With reagrds to the
date issue not sure. Is there anywhere to look.

I have just made the final draft of the button we spoke about and now it
wont wirk any ideas? just entered all the fields with data and then hit the
button and when one of the fields is selected you can carry on adding info?

thanks darren

Klatuu said:
--
Dave Hargis, Microsoft Access MVP


Darren said:
Ok thanks for the advice Not to worry about the grey boxes. I want this to be
as simpleas possible.

with regards to auto number issue. I need to have a new number allocated to
each new call that is inputed. I have all the other boxes for the relevant
info to be stored, and have even created a button that will create a new
feild in the form. I need the number to be used only once and to start at
whaterver number i like. Can you sugest anything.

You can create a fake autonumber. Each time you add a new record you can
determine the highest number currently in the field and add 1 to it. This
you do in the form's current event. You only do it for new records:

If Me.NewRecord Then
Me.txtCallNumber = Nz(DLookup("[CallNumber]", "CallTable"),0) + 1
End If

If you want to start at a specific number, put a record in the table with
the number you want to start with - 1 (I think), because the next new record
will be one higher than the value in the record you start with.
Also the date has worked fine except it comes out at 1428??? Any help would
be great.

Is the table field a date data type? Are you using any formatting on the
control?
 
everytime i create a new field the edit button will only work if you go to
the code and come out of it
hope this heps

Darren said:
I think i will leave the number issue for the moment. With reagrds to the
date issue not sure. Is there anywhere to look.

I have just made the final draft of the button we spoke about and now it
wont wirk any ideas? just entered all the fields with data and then hit the
button and when one of the fields is selected you can carry on adding info?

thanks darren

Klatuu said:
--
Dave Hargis, Microsoft Access MVP


Darren said:
Ok thanks for the advice Not to worry about the grey boxes. I want this to be
as simpleas possible.

with regards to auto number issue. I need to have a new number allocated to
each new call that is inputed. I have all the other boxes for the relevant
info to be stored, and have even created a button that will create a new
feild in the form. I need the number to be used only once and to start at
whaterver number i like. Can you sugest anything.

You can create a fake autonumber. Each time you add a new record you can
determine the highest number currently in the field and add 1 to it. This
you do in the form's current event. You only do it for new records:

If Me.NewRecord Then
Me.txtCallNumber = Nz(DLookup("[CallNumber]", "CallTable"),0) + 1
End If

If you want to start at a specific number, put a record in the table with
the number you want to start with - 1 (I think), because the next new record
will be one higher than the value in the record you start with.
Also the date has worked fine except it comes out at 1428??? Any help would
be great.

Is the table field a date data type? Are you using any formatting on the
control?
:


--
Dave Hargis, Microsoft Access MVP


:

Many Many thanks for that.

Just a couple of other questions.

1, In a date field, is there a way of auto inserting the date?
First order of business. Forms do not have fields. Tables and queries have
fields. Forms have controls and some of those controls can be bound to
fields in the form's record source. But the short answer is if you want the
date to be today's date, put Date() in the control's Default Value property.
When you create a new record, it will automatically populate the control with
the date.

2, Also Is there a way of changing the number that a auto number starts from?
It is possible, but by asking the question, I know you are not using an
autonumber field correctly. You should not care about the value of an
autonumber and users should never see it. Autonumber field are just a tool
for creating unique value to be used as primary keys and relating tables. If
you are using it for something else, post back with what you want to do and
we can help find a better approach.

3, And on a final note now i have locked out the fields information, is
there a way of turning the feild boxes grey for example?

Yes, but it take a lot more code because you have to go through the controls
collection of the form and set each editable control's Enabled property to
False.

Many thanks again

:

In the Click Event of the command button:

With Me
.AllowEdits = False
.AllowDeletions = False
End With

The other thing will be to allow them back on. You could either use toggle
buttons in an option group to turn it on and off or you can put the same code
in the Form Current event except replace False with True. With this method,
whenever you move to a different or new record, editing will be allowed
again until the button is clicked.
--
Dave Hargis, Microsoft Access MVP


:

I have created a small call logging database on access. i want to create a
button that when pressed will lock all of the information in the feilds. I am
very new to this so any help would be great.
 
try a minor modification

With Me
If Me.dirty then Me.Dirty = False '(save the changes)
.AllowEdits = False
.AllowDeletions = False
End With

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

everytime i create a new field the edit button will only work if you go to
the code and come out of it
hope this heps

Darren said:
I think i will leave the number issue for the moment. With reagrds to the
date issue not sure. Is there anywhere to look.

I have just made the final draft of the button we spoke about and now it
wont wirk any ideas? just entered all the fields with data and then hit the
button and when one of the fields is selected you can carry on adding info?

thanks darren

Klatuu said:
--
Dave Hargis, Microsoft Access MVP


:

Ok thanks for the advice Not to worry about the grey boxes. I want this to be
as simpleas possible.

with regards to auto number issue. I need to have a new number allocated to
each new call that is inputed. I have all the other boxes for the relevant
info to be stored, and have even created a button that will create a new
feild in the form. I need the number to be used only once and to start at
whaterver number i like. Can you sugest anything.
You can create a fake autonumber. Each time you add a new record you can
determine the highest number currently in the field and add 1 to it. This
you do in the form's current event. You only do it for new records:

If Me.NewRecord Then
Me.txtCallNumber = Nz(DLookup("[CallNumber]", "CallTable"),0) + 1
End If

If you want to start at a specific number, put a record in the table with
the number you want to start with - 1 (I think), because the next new record
will be one higher than the value in the record you start with.

Also the date has worked fine except it comes out at 1428??? Any help would
be great.
Is the table field a date data type? Are you using any formatting on the
control?



:

--
Dave Hargis, Microsoft Access MVP


:

Many Many thanks for that.

Just a couple of other questions.

1, In a date field, is there a way of auto inserting the date?
First order of business. Forms do not have fields. Tables and queries have
fields. Forms have controls and some of those controls can be bound to
fields in the form's record source. But the short answer is if you want the
date to be today's date, put Date() in the control's Default Value property.
When you create a new record, it will automatically populate the control with
the date.
2, Also Is there a way of changing the number that a auto number starts from?
It is possible, but by asking the question, I know you are not using an
autonumber field correctly. You should not care about the value of an
autonumber and users should never see it. Autonumber field are just a tool
for creating unique value to be used as primary keys and relating tables. If
you are using it for something else, post back with what you want to do and
we can help find a better approach.
3, And on a final note now i have locked out the fields information, is
there a way of turning the feild boxes grey for example?
Yes, but it take a lot more code because you have to go through the controls
collection of the form and set each editable control's Enabled property to
False.
Many thanks again

:

In the Click Event of the command button:

With Me
.AllowEdits = False
.AllowDeletions = False
End With

The other thing will be to allow them back on. You could either use toggle
buttons in an option group to turn it on and off or you can put the same code
in the Form Current event except replace False with True. With this method,
whenever you move to a different or new record, editing will be allowed
again until the button is clicked.
--
Dave Hargis, Microsoft Access MVP


:

I have created a small call logging database on access. i want to create a
button that when pressed will lock all of the information in the feilds. I am
very new to this so any help would be great.
 
Thanks John for the advice. Any idea why the date is coming up with 1492? and
not todays date. I have Date() in the default control field?

Many thnks

John Spencer said:
try a minor modification

With Me
If Me.dirty then Me.Dirty = False '(save the changes)
.AllowEdits = False
.AllowDeletions = False
End With

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

everytime i create a new field the edit button will only work if you go to
the code and come out of it
hope this heps

Darren said:
I think i will leave the number issue for the moment. With reagrds to the
date issue not sure. Is there anywhere to look.

I have just made the final draft of the button we spoke about and now it
wont wirk any ideas? just entered all the fields with data and then hit the
button and when one of the fields is selected you can carry on adding info?

thanks darren

:

--
Dave Hargis, Microsoft Access MVP


:

Ok thanks for the advice Not to worry about the grey boxes. I want this to be
as simpleas possible.

with regards to auto number issue. I need to have a new number allocated to
each new call that is inputed. I have all the other boxes for the relevant
info to be stored, and have even created a button that will create a new
feild in the form. I need the number to be used only once and to start at
whaterver number i like. Can you sugest anything.
You can create a fake autonumber. Each time you add a new record you can
determine the highest number currently in the field and add 1 to it. This
you do in the form's current event. You only do it for new records:

If Me.NewRecord Then
Me.txtCallNumber = Nz(DLookup("[CallNumber]", "CallTable"),0) + 1
End If

If you want to start at a specific number, put a record in the table with
the number you want to start with - 1 (I think), because the next new record
will be one higher than the value in the record you start with.

Also the date has worked fine except it comes out at 1428??? Any help would
be great.
Is the table field a date data type? Are you using any formatting on the
control?



:

--
Dave Hargis, Microsoft Access MVP


:

Many Many thanks for that.

Just a couple of other questions.

1, In a date field, is there a way of auto inserting the date?
First order of business. Forms do not have fields. Tables and queries have
fields. Forms have controls and some of those controls can be bound to
fields in the form's record source. But the short answer is if you want the
date to be today's date, put Date() in the control's Default Value property.
When you create a new record, it will automatically populate the control with
the date.
2, Also Is there a way of changing the number that a auto number starts from?
It is possible, but by asking the question, I know you are not using an
autonumber field correctly. You should not care about the value of an
autonumber and users should never see it. Autonumber field are just a tool
for creating unique value to be used as primary keys and relating tables. If
you are using it for something else, post back with what you want to do and
we can help find a better approach.
3, And on a final note now i have locked out the fields information, is
there a way of turning the feild boxes grey for example?
Yes, but it take a lot more code because you have to go through the controls
collection of the form and set each editable control's Enabled property to
False.
Many thanks again

:

In the Click Event of the command button:

With Me
.AllowEdits = False
.AllowDeletions = False
End With

The other thing will be to allow them back on. You could either use toggle
buttons in an option group to turn it on and off or you can put the same code
in the Form Current event except replace False with True. With this method,
whenever you move to a different or new record, editing will be allowed
again until the button is clicked.
--
Dave Hargis, Microsoft Access MVP


:

I have created a small call logging database on access. i want to create a
button that when pressed will lock all of the information in the feilds. I am
very new to this so any help would be great.
 
-- Check the format property of the control.
-- Check and make sure you don't have function named Date

Beyond that I have no other ideas.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top