Required Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 
First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If
 
It didn't work. I don't think I said the right thing. I have a command
button that prints a report. I don't want it to print if the two fields are
blank.
Oh I don't know what check the field value means

Ofer said:
First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If


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


Chey said:
I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 
On the OnClick event of the Button, write the code before running the report

If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
Me.[Facilities visiting].SetFocus
Exit Sub
End If
Docmd.OpenReport "ReportName"

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


Chey said:
It didn't work. I don't think I said the right thing. I have a command
button that prints a report. I don't want it to print if the two fields are
blank.
Oh I don't know what check the field value means

Ofer said:
First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If


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


Chey said:
I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then


If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then


These two parts are red. When I run the code they become highlighted.
Also, I don't remember, but how do I do a where condition under a code?

I know how under a macro.

Thanks Chey


Ofer said:
On the OnClick event of the Button, write the code before running the report

If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
Me.[Facilities visiting].SetFocus
Exit Sub
End If
Docmd.OpenReport "ReportName"

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


Chey said:
It didn't work. I don't think I said the right thing. I have a command
button that prints a report. I don't want it to print if the two fields are
blank.
Oh I don't know what check the field value means

Ofer said:
First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If


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


:

I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 
The where, is the If.

Make into one line, the box might have cut this line into two, and this is
why you are gettinf it in Red

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


Chey said:
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then


If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then


These two parts are red. When I run the code they become highlighted.
Also, I don't remember, but how do I do a where condition under a code?

I know how under a macro.

Thanks Chey


Ofer said:
On the OnClick event of the Button, write the code before running the report

If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
Me.[Facilities visiting].SetFocus
Exit Sub
End If
Docmd.OpenReport "ReportName"

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


Chey said:
It didn't work. I don't think I said the right thing. I have a command
button that prints a report. I don't want it to print if the two fields are
blank.
Oh I don't know what check the field value means

:

First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If


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


:

I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 
Oh no, I got that to work now. I had a typo.
When I print the report, I want it to print a certain part.
For example
The where condition that I am thinking of is
when you have to take the underlying query and equal it to something on the
form.
My underlying query is Travel with no layovers, (Field) I want TA # last
3 equal to (on current form) Travel Request 0 Layovers (Field) TA # last 3.
Does this make sense.?


Ofer said:
The where, is the If.

Make into one line, the box might have cut this line into two, and this is
why you are gettinf it in Red

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


Chey said:
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then


If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then


These two parts are red. When I run the code they become highlighted.
Also, I don't remember, but how do I do a where condition under a code?

I know how under a macro.

Thanks Chey


Ofer said:
On the OnClick event of the Button, write the code before running the report

If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
Me.[Facilities visiting].SetFocus
Exit Sub
End If
Docmd.OpenReport "ReportName"

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


:

It didn't work. I don't think I said the right thing. I have a command
button that prints a report. I don't want it to print if the two fields are
blank.
Oh I don't know what check the field value means

:

First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If


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


:

I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 
I guess the proper term is where clause.
Thanks agian

Ofer said:
The where, is the If.

Make into one line, the box might have cut this line into two, and this is
why you are gettinf it in Red

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


Chey said:
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then


If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then


These two parts are red. When I run the code they become highlighted.
Also, I don't remember, but how do I do a where condition under a code?

I know how under a macro.

Thanks Chey


Ofer said:
On the OnClick event of the Button, write the code before running the report

If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
Me.[Facilities visiting].SetFocus
Exit Sub
End If
Docmd.OpenReport "ReportName"

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


:

It didn't work. I don't think I said the right thing. I have a command
button that prints a report. I don't want it to print if the two fields are
blank.
Oh I don't know what check the field value means

:

First, you can make this code shorter

Me.[Travel Description].Visible = Me.[LS]
Me.[Facilities visiting].Visible = Me.[LS]

About the second question, on the before update event of the form, check the
field value
If Me.[LS] And (IsNull(Me.[Travel Description]) Or Me.[Travel
Description]="") Then
Msgbox "Travel Description must be filled
cancel=True ' wont let exit the form
Me.[Travel Description].SetFocus
Exit Sub
End If
If Me.[LS] And (IsNull(Me.[Facilities visiting]) Or Me.[Facilities
visiting]="") Then
Msgbox "Facilities visiting must be filled
cancel=True ' wont let exit the form
Me.[Facilities visiting].SetFocus
End If


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


:

I have this code
If [LS] = True Then
[Travel Description].Visible = True
Else
[Travel Description].Visible = False
End If

If [LS] = True Then
[Facilities visiting].Visible = True
Else
[Facilities visiting].Visible = False
End If

Now when the two fields are visable I want them to be required. If not
visiable then not required. Can someone tell me how I can do this?
 

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

Similar Threads

Want to alter code with out screwing up 5
visable 3
Clearing text boxes based on combo selections 3
ByPass key ms access 2016 0
if statement not working 3
visable 1
.VISIBLE Not Working Perfectly 2
2165 2

Back
Top