Enter Data Script Works But Not During Data Entry

R

Robert T

Hello:

I have a simple little checkbook application that has a text field called
[Trans_Type]. The only two choices are "Debit" and "Credit". There are two
currency fields, [Debits] and [Credits] that should be enabled or disabled
depening upon selection made in the Trans_Type field. In other words, if it
is a "debit", then the [credits] currency field should be disabled and the
opposite is true.

The script works perfectly wnen moving from record to record, however, it
does NOT work during Data Entry and that's really the purpose of the script.
If I'm entering a new record, the debits field is always grayed out and the
credits field is always enabled, even if I select "Debit" in the Trans_Type
field.

Here is the OnCurrent Event script, I'm hoping someone can explain what I'm
doing wrong.

Private Sub Form_Current()
'If the field Trans_Type is a Debit, Disable the Credits Field
'If the field Trans_Type is a Credit, Disable the Debits Field

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If
End Sub

Thanks,
RT
 
I

Ivan Grozney

Robert,

In your AFTER UPDATE for TRANS_TYPE put in the same code

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If

HTH

Vanya
 
R

Robert T

Hello Ivan:

Yes! I tried your excellent suggestion and it worked. I'm new to Access so I
have to ask you why didn't the OnCurrent Event do the trick?

Thanks so much
RT

Ivan Grozney said:
Robert,

In your AFTER UPDATE for TRANS_TYPE put in the same code

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If

HTH

Vanya




Robert T said:
Hello:

I have a simple little checkbook application that has a text field called
[Trans_Type]. The only two choices are "Debit" and "Credit". There are two
currency fields, [Debits] and [Credits] that should be enabled or disabled
depening upon selection made in the Trans_Type field. In other words, if it
is a "debit", then the [credits] currency field should be disabled and the
opposite is true.

The script works perfectly wnen moving from record to record, however, it
does NOT work during Data Entry and that's really the purpose of the script.
If I'm entering a new record, the debits field is always grayed out and the
credits field is always enabled, even if I select "Debit" in the Trans_Type
field.

Here is the OnCurrent Event script, I'm hoping someone can explain what I'm
doing wrong.

Private Sub Form_Current()
'If the field Trans_Type is a Debit, Disable the Credits Field
'If the field Trans_Type is a Credit, Disable the Debits Field

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If
End Sub

Thanks,
RT
 
I

Ivan Grozney

Robert,

I am glad it worked for you.

The on current is when the form is *current*, meaning changed from one
record to the next. Since you are just changing the value of a field on the
current form, then it is the after update that needs to be run.

Vanya

Robert T said:
Hello Ivan:

Yes! I tried your excellent suggestion and it worked. I'm new to Access so I
have to ask you why didn't the OnCurrent Event do the trick?

Thanks so much
RT

Ivan Grozney said:
Robert,

In your AFTER UPDATE for TRANS_TYPE put in the same code

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If

HTH

Vanya




Robert T said:
Hello:

I have a simple little checkbook application that has a text field called
[Trans_Type]. The only two choices are "Debit" and "Credit". There are two
currency fields, [Debits] and [Credits] that should be enabled or disabled
depening upon selection made in the Trans_Type field. In other words, if it
is a "debit", then the [credits] currency field should be disabled and the
opposite is true.

The script works perfectly wnen moving from record to record, however, it
does NOT work during Data Entry and that's really the purpose of the script.
If I'm entering a new record, the debits field is always grayed out and the
credits field is always enabled, even if I select "Debit" in the Trans_Type
field.

Here is the OnCurrent Event script, I'm hoping someone can explain what I'm
doing wrong.

Private Sub Form_Current()
'If the field Trans_Type is a Debit, Disable the Credits Field
'If the field Trans_Type is a Credit, Disable the Debits Field

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If
End Sub

Thanks,
RT
 
R

Robert T

Thanks so much Ivan for the advice and follow up explanation. Have a great
day and maybe you can help me again in the near future?

RT

Ivan Grozney said:
Robert,

I am glad it worked for you.

The on current is when the form is *current*, meaning changed from one
record to the next. Since you are just changing the value of a field on the
current form, then it is the after update that needs to be run.

Vanya

Robert T said:
Hello Ivan:

Yes! I tried your excellent suggestion and it worked. I'm new to Access so I
have to ask you why didn't the OnCurrent Event do the trick?

Thanks so much
RT

Ivan Grozney said:
Robert,

In your AFTER UPDATE for TRANS_TYPE put in the same code

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If

HTH

Vanya




:

Hello:

I have a simple little checkbook application that has a text field called
[Trans_Type]. The only two choices are "Debit" and "Credit". There are two
currency fields, [Debits] and [Credits] that should be enabled or disabled
depening upon selection made in the Trans_Type field. In other words, if it
is a "debit", then the [credits] currency field should be disabled and the
opposite is true.

The script works perfectly wnen moving from record to record, however, it
does NOT work during Data Entry and that's really the purpose of the script.
If I'm entering a new record, the debits field is always grayed out and the
credits field is always enabled, even if I select "Debit" in the Trans_Type
field.

Here is the OnCurrent Event script, I'm hoping someone can explain what I'm
doing wrong.

Private Sub Form_Current()
'If the field Trans_Type is a Debit, Disable the Credits Field
'If the field Trans_Type is a Credit, Disable the Debits Field

If Me![TRANS_TYPE] = "Debit" Then
Me![DEBITS].Enabled = True
Me![CREDITS].Enabled = False
Else
Me![CREDITS].Enabled = True
Me![DEBITS].Enabled = False
End If
End Sub

Thanks,
RT
 

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

Top