Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How-to set the previous record value as the default value?

Status
Not open for further replies.

petchong40

Technical User
Feb 20, 2003
1
MY
I have a Yes/No field that need to set the previous input as the default value to speed up the data entry. May somebody help.

Detail: The table has only 8 fields, with 3 Yes/No field. I've design a form for the data entry which those 3 Y/N field display with Tab Stop = No to speedup the data entry.

I would like to set the current record's 3 Y/N field as the next record's default value. Anybody can help?

Thanks in advance...
 
Hi pet,

Without knowing your VBA skills I've opted for the simplest solution.

In a module type this:
Code:
Dim ChkBoxArray As Variant
'The following array holds 4 values:
'ChkBoxArray(0) holds '0' if first record, '1' otherwise.
'ChkBoxArray(1,2 & 3) hold each chkbox value. 
 
ChkBoxArray = Array(3)

In the form where the 3 checkboxes are, type this:

'This function first checks to see if this is the first
'record to be edited - if it is, then the code won't run as
'the user needs to manually enter data.
'If it isn't, it populates the checkboxes with values
'stored from the last record....
'It is called from the form <On Current> event.
Code:
sub SetChkBoxes
  if(ChkBoxArray(0) = 1) then 'The array has been filled.
    chkBox1 = ChkBoxArray(1)
    chkBox1 = ChkBoxArray(2)
    chkBox3 = ChkBoxArray(3) 
  endif
end sub
'This function sets values in the array every time a
'checkbox is clicked (ready for next record to use).
'It's called by each of the 3 checkboxe's <On Click>
'events...
Code:
sub SetChkArray
  chkBoxArray(0) = 1
  chkBoxArray(1) = chkBox1
  chkBoxArray(2) = chkBox2
  chkBoxArray(3) = chkBox3
end sub

In the form <On Current> event type this....

Code:
call setChkBoxes

In the <On Click> event of all 3 checkboxes type this...

Code:
call SetChkArray

----------------------------------------------------
Someone else will supply a more eloquent solution, but remember that if a user goes back to a previous record, THAT record will default IT'S checkboxes also.

You could also store records in memory, bookmark a record etc. but would still have the same problem if a user goes back to a previous record.
This would involve some complexity to get around.

Regards,

Darrylle &quot;Never argue with an idiot, he'll bring you down to his level - then beat you with experience.&quot; darrylles@totalise.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top