Repeat the values entered in a textbox for next record

  • Thread starter Thread starter Wasim Yasin via AccessMonster.com
  • Start date Start date
W

Wasim Yasin via AccessMonster.com

Dear all
I want for time saving that when a value of a field is entered and then so
for next fileds... When press Enter for next record then this value of a
particular field displayed for new record. and user just enter at this
field rather than typing the same stuff.waitibg for a quick response.
 
At the point where you are saving the record e.g. cmdSave_Click

do the following

me.txtmyTextBox.DefaultValue = me.txtmyTextBox.Value

what the above line is doing is setting the default value of the textbox to
the currentvalue so when you add a new record that value will be the
default, this will not persist after closing the form and opening again

you need to save the design of the form

DoCmd.Save acForm, Me.Name

to keep the default values
 
Thanx a lot of u. It is working properly. can u tell me the defination of
line Docmd......?
 
It was in my original reply but,

DoCmd.Save acForm, Me.Name

all the above line does is save the design of the current form the code is
running from

DoCmd.Close acForm, Me.Name, acSaveYes

the above line will save the design of the form when you are trying to close
it.

if you need more help with the docmd search the Access help, all I can say
is the docmd command does a lot of different things within Access, if you
have a specific question post it up.
 
Insert the value that is in the same field in the previous record
Open a Datasheet.


Click in the field in which you want to insert the value.


Press CTRL+APOSTROPHE (').

Eric
 
Thanx a lot Alen.
In continuation of my query now I need to check the repeated value.It may
be that the user continue the punching and forget to change the values of
that field. So after every 10 records entered the user will get a message
to check the values either repeated or has been changed.
 
A unbound hidden textbox on the form that is keeping count, and every time
you add a new record increment the counter by 1, when it reaches 10,
something like

*** Air code ***

....do your form save here

' then increment the counter
me.txtCounter.value = val(me.txtCounter.value)+1

if val(me.txtCounter.value) >=10 then
if msgbox("Are you sure you want to keep the default
value?",vbyesno+vbquestion,"Confirmation")=vbno then
me.txtYourTextBox.DefaultValue = ""
.. change the defaults for all the fields
end if
me.txtCounter.value = 0
end if

the above code is untested and is just an indication of what you need to do.
you may want to put the code in the 'on current' or 'before update' event
for the form depending on what you are trying to do.
 
Dear Alex

I found a run time error that when I change the default value of the field.
How can I change it? Please reply hurry bcaz I had stopped the punching in
my lab and users r waiting for my response.

Thanx a lot.
 
post your code that is erroring not just the specific line but the code
block
 
The code is here.

Private Sub Emp_num_BeforeUpdate(Cancel As Integer)
Me.Emp_num.DefaultValue = Me.Emp_num.Value
DoCmd.Save acForm, Me.Name

End Sub
 
make sure you me.Emp_num.value is not null

e.g.

On Error Goto Err_Emp_num_BeforeUpdate
10 if not isnull(me.Emp_num.value) then
20 me.Emp_num.DefaultValue = me.Emp_num.value
30 end if
40 Docmd.Save acForm, me.name ' you should only need this if you are closing
the form.
Exit_Emp_num_BeforeUpdate
50 Exit sub
Err_Emp_num_BeforeUpdate:
msgbox err.number & " " & Err.description & " " & erl()
resume next

if this is not the answer what is the error description and error number

put the above code in your code block, it will tell you which line and what
error is happening.
 
Dear Alex
I 'm facing a new problem. As the user enter date value in the date field
it convert it into time and next field show '#value'. Where i use ur Error
listing.
 
Back
Top