AfterUpdate Property

G

Guest

In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 
G

Guest

On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If
 
G

Guest

I wrote this in TextBox 2 before update property and it is not working.
Should I put this in Textbox 1 after update? Sorry, I took so long in
replying but, I do appreciate your help.



Ofer said:
On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 
G

Guest

As I wrote in the first post, put this code in the before update event of the
form, not the text box, so the validation will happen before the record is
saved.

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
I wrote this in TextBox 2 before update property and it is not working.
Should I put this in Textbox 1 after update? Sorry, I took so long in
replying but, I do appreciate your help.



Ofer said:
On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 
G

Guest

You did write that and I am sorry. I did apply this in the forms before
update and it did work.
One more question on this though. I have a total of 8 fields that I want to
apply this same rule to. How would I write this as cleanly as possible? Do I
just continue writing the same thing after the Me.[TextBox 2].SetFocus and
when all 8 fields are compled write. End IF

Thanks again.

Ofer said:
As I wrote in the first post, put this code in the before update event of the
form, not the text box, so the validation will happen before the record is
saved.

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
I wrote this in TextBox 2 before update property and it is not working.
Should I put this in Textbox 1 after update? Sorry, I took so long in
replying but, I do appreciate your help.



Ofer said:
On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If

--
\\// Live Long and Prosper \\//
BS"D


:

In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 
G

Guest

No need to appologize (I have no idea how you write this word), English is
not my main language so I hope I didn't sound to harsh (another word). I just
hope they had speller in this discssion group, and I'm to lazy to write it
first in word.

Any way, to your question.
It's all depend on what you want to do, if you want a specific message for
each field and then set the focus, then yes, you can create this criteria for
each field separetly.
And you need to add
exit sub
in each IF, so it wont prompt the user with four messages or more, it will
exit the checking on the first error

===========================================
But if the messae is not important, then you can try something like

If (IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1])) Or
(IsNull(Me.[Textbox 3]) And Not IsNull(Me.[Textbox 4])) Or
(IsNull(Me.[Textbox 5]) And Not IsNull(Me.[Textbox 6])) Or
(IsNull(Me.[Textbox 7]) And Not IsNull(Me.[Textbox 8])) Then
MsgBox "Must complete fields"
Cancel = True 'wont let the user continue
Emd If

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
You did write that and I am sorry. I did apply this in the forms before
update and it did work.
One more question on this though. I have a total of 8 fields that I want to
apply this same rule to. How would I write this as cleanly as possible? Do I
just continue writing the same thing after the Me.[TextBox 2].SetFocus and
when all 8 fields are compled write. End IF

Thanks again.

Ofer said:
As I wrote in the first post, put this code in the before update event of the
form, not the text box, so the validation will happen before the record is
saved.

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
I wrote this in TextBox 2 before update property and it is not working.
Should I put this in Textbox 1 after update? Sorry, I took so long in
replying but, I do appreciate your help.



:

On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If

--
\\// Live Long and Prosper \\//
BS"D


:

In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 
G

Guest

I will try that. Thank you for all your help.

Ofer said:
No need to appologize (I have no idea how you write this word), English is
not my main language so I hope I didn't sound to harsh (another word). I just
hope they had speller in this discssion group, and I'm to lazy to write it
first in word.

Any way, to your question.
It's all depend on what you want to do, if you want a specific message for
each field and then set the focus, then yes, you can create this criteria for
each field separetly.
And you need to add
exit sub
in each IF, so it wont prompt the user with four messages or more, it will
exit the checking on the first error

===========================================
But if the messae is not important, then you can try something like

If (IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1])) Or
(IsNull(Me.[Textbox 3]) And Not IsNull(Me.[Textbox 4])) Or
(IsNull(Me.[Textbox 5]) And Not IsNull(Me.[Textbox 6])) Or
(IsNull(Me.[Textbox 7]) And Not IsNull(Me.[Textbox 8])) Then
MsgBox "Must complete fields"
Cancel = True 'wont let the user continue
Emd If

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
You did write that and I am sorry. I did apply this in the forms before
update and it did work.
One more question on this though. I have a total of 8 fields that I want to
apply this same rule to. How would I write this as cleanly as possible? Do I
just continue writing the same thing after the Me.[TextBox 2].SetFocus and
when all 8 fields are compled write. End IF

Thanks again.

Ofer said:
As I wrote in the first post, put this code in the before update event of the
form, not the text box, so the validation will happen before the record is
saved.

--
\\// Live Long and Prosper \\//
BS"D


:

I wrote this in TextBox 2 before update property and it is not working.
Should I put this in Textbox 1 after update? Sorry, I took so long in
replying but, I do appreciate your help.



:

On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If

--
\\// Live Long and Prosper \\//
BS"D


:

In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 
G

Guest

I did place all this in the before update property but, I have one more
question.
When I was testing this in the form, I do get the correct Msg that I wrote
but, I also get the message "You can't go to the specified recordset". What
does this mean and how can I get rid of it? Here is my code below: Thanks
again

If IsNull(Me.[PendingBillHrs]) And Not IsNull(Me.[PendingBill]) Then
MsgBox "You must enter the time worked on the Pending Bill"
Cancel = True
Me.[PendingBillHrs].SetFocus
Exit Sub

End If

If IsNull(Me.BillingHrs) And Not IsNull(Me.Billing) Then
MsgBox "You must enter the time worked on Billings"
Cancel = True
Me.[BillingHrs].SetFocus
Exit Sub

End If

If IsNull(Me.[PendingAsmtHrs]) And Not IsNull(Me.[PendingAsmt]) Then
MsgBox "You must enter the time worked on Pending Assessments"
Cancel = True
Me.[PendingAsmtHrs].SetFocus
Exit Sub

End If


If IsNull(Me.[UnCertAsmtHrs]) And Not IsNull(Me.[UnCertAsmt]) Then
MsgBox "You must enter the time worked on UnCert Assessments"
Cancel = True
Me.[UnCertAsmtHrs].SetFocus
Exit Sub

End If

If IsNull(Me.[CertifiedAsmtHrs]) And Not IsNull(Me.[CertifiedAsmt]) Then
MsgBox "You must enter the time worked on Certified Assessments"
Cancel = True
Me.[CertifiedAsmtHrs].SetFocus
Exit Sub

End If


If IsNull(Me.[PetitionsHrs]) And Not IsNull(Me.[Petitions]) Then
MsgBox "You must enter the time worked on Petitions"
Cancel = True
Me.[PetitionsHrs].SetFocus
Exit Sub

End If


If IsNull(Me.[FinalDeterminationHrs]) And Not
IsNull(Me.[FinalDetermination]) Then
MsgBox "You must enter the time worked on Final Determinations"
Cancel = True
Me.[FinalDeterminationHrs].SetFocus
Exit Sub

End If


If IsNull(Me.[EditHrs]) And Not IsNull(Me.[Edits]) Then
MsgBox "You must enter the time worked on Edits"
Cancel = True
Me.[EditHrs].SetFocus
Exit Sub


End If



End Sub



Melissa said:
I will try that. Thank you for all your help.

Ofer said:
No need to appologize (I have no idea how you write this word), English is
not my main language so I hope I didn't sound to harsh (another word). I just
hope they had speller in this discssion group, and I'm to lazy to write it
first in word.

Any way, to your question.
It's all depend on what you want to do, if you want a specific message for
each field and then set the focus, then yes, you can create this criteria for
each field separetly.
And you need to add
exit sub
in each IF, so it wont prompt the user with four messages or more, it will
exit the checking on the first error

===========================================
But if the messae is not important, then you can try something like

If (IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1])) Or
(IsNull(Me.[Textbox 3]) And Not IsNull(Me.[Textbox 4])) Or
(IsNull(Me.[Textbox 5]) And Not IsNull(Me.[Textbox 6])) Or
(IsNull(Me.[Textbox 7]) And Not IsNull(Me.[Textbox 8])) Then
MsgBox "Must complete fields"
Cancel = True 'wont let the user continue
Emd If

--
\\// Live Long and Prosper \\//
BS"D


Melissa said:
You did write that and I am sorry. I did apply this in the forms before
update and it did work.
One more question on this though. I have a total of 8 fields that I want to
apply this same rule to. How would I write this as cleanly as possible? Do I
just continue writing the same thing after the Me.[TextBox 2].SetFocus and
when all 8 fields are compled write. End IF

Thanks again.

:

As I wrote in the first post, put this code in the before update event of the
form, not the text box, so the validation will happen before the record is
saved.

--
\\// Live Long and Prosper \\//
BS"D


:

I wrote this in TextBox 2 before update property and it is not working.
Should I put this in Textbox 1 after update? Sorry, I took so long in
replying but, I do appreciate your help.



:

On the before update event of the form, enter the code

If IsNull(Me.[Textbox 2]) And Not IsNull(Me.[Textbox 1]) Then
MsgBox "TextBox 2 must be filled if Text Box 1 Is"
Cancel = True 'wont let the user continue
Me.[TextBox2].SetFocus
Emd If

--
\\// Live Long and Prosper \\//
BS"D


:

In access if a user enters data in Textbox 1 for example and does not enter
data into Textbox 2, how can I code that to say,
"If data is in Txtbox 1 then Txtbox 2 is required to be completed? Is there
a simple code you could help me with?
Thanks
 

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