By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,705 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,705 IT Pros & Developers. It's quick & easy.

Copying information to next record

P: 2
Hi i have a text box that i want to copy whatever i have in it to the next record in the same textbox and this is all determined if the checkbox next to it is checked.
I have the following code for it so far but its not working.

Private Sub txtTRKNUM_AfterUpdate()
If chkTRACKLOCK.Value = Checked Then
txtTRKNUM.DefaultValue = txtTRKNUM
End If
End Sub

Is this the approach i should take?
Aug 2 '07 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,669
Hi i have a text box that i want to copy whatever i have in it to the next record in the same textbox and this is all determined if the checkbox next to it is checked.
I have the following code for it so far but its not working.

Private Sub txtTRKNUM_AfterUpdate()
If chkTRACKLOCK.Value = Checked Then
txtTRKNUM.DefaultValue = txtTRKNUM
End If
End Sub

Is this the approach i should take?
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTRKNUM_AfterUpdate()
  2.   If Not IsNull(Me![txtTRKNUM]) And Me![chkTRACKLOCK] = True Then
  3.     Me![txtTRKNUM].DefaultValue = "'" & Me![txtTRKNUM] & "'"
  4.   End If
  5. End Sub
  6.  
Aug 5 '07 #2

missinglinq
Expert 2.5K+
P: 3,532
ADezii's code will work, but I see a possible problem here, in that Me![txtTRKNUM] will continue to have a default value, whether the box is checked or not, in some circumstances, i.e.

Record A
Me![txtTRKNUM] = "123"
[chkTRACKLOCK] = True
Me![txtTRKNUM].DefaultValue = "123"

Record B
Me![txtTRKNUM] = "123"
[chkTRACKLOCK] = False
Me![txtTRKNUM].DefaultValue will still be "123" and carried forward

Record C
Me![txtTRKNUM] = "123" because the default value is still "123" and will continue to be, until a new value is entered for [txtTRKNUM] and made the default by checking [chkTRACKLOCK] or until the form is closed.

Perhaps an Else statement is in order, setting the default to an empty string if the checkbox is unchecked:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTRKNUM_AfterUpdate()
  2.    If Not IsNull(Me![txtTRKNUM]) And Me![chkTRACKLOCK] = True Then
  3.      Me![txtTRKNUM].DefaultValue = "'" & Me![txtTRKNUM] & "'"
  4. Else 
  5.      Me![txtTRKNUM].DefaultValue = " "
  6.    End If
  7.  End Sub
Welcome to TheScripts!

Linq ;0)>
Aug 5 '07 #3

ADezii
Expert 5K+
P: 8,669
ADezii's code will work, but I see a possible problem here, in that Me![txtTRKNUM] will continue to have a default value, whether the box is checked or not, in some circumstances, i.e.

Record A
Me![txtTRKNUM] = "123"
[chkTRACKLOCK] = True
Me![txtTRKNUM].DefaultValue = "123"

Record B
Me![txtTRKNUM] = "123"
[chkTRACKLOCK] = False
Me![txtTRKNUM].DefaultValue will still be "123" and carried forward

Record C
Me![txtTRKNUM] = "123" because the default value is still "123" and will continue to be, until a new value is entered for [txtTRKNUM] and made the default by checking [chkTRACKLOCK] or until the form is closed.

Perhaps an Else statement is in order, setting the default to an empty string if the checkbox is unchecked:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTRKNUM_AfterUpdate()
  2.    If Not IsNull(Me![txtTRKNUM]) And Me![chkTRACKLOCK] = True Then
  3.      Me![txtTRKNUM].DefaultValue = "'" & Me![txtTRKNUM] & "'"
  4. Else 
  5.      Me![txtTRKNUM].DefaultValue = " "
  6.    End If
  7.  End Sub
Welcome to TheScripts!

Linq ;0)>
Good point, ling. I'll redirect the OP to reference your Post. Thanks.
Aug 5 '07 #4

ADezii
Expert 5K+
P: 8,669
Hi i have a text box that i want to copy whatever i have in it to the next record in the same textbox and this is all determined if the checkbox next to it is checked.
I have the following code for it so far but its not working.

Private Sub txtTRKNUM_AfterUpdate()
If chkTRACKLOCK.Value = Checked Then
txtTRKNUM.DefaultValue = txtTRKNUM
End If
End Sub

Is this the approach i should take?
See Post #3 by missingling for the correct approach.
Aug 5 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.