Help with an If Statement

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

Guest

Private Sub Allocated_AfterUpdate()
If [Allocated] = True Then
[Job] = [Forms]![Jobs Entry]![Job]
End If
End Sub

Im trying to write a simple if statement, but cant get it to work, as
[Allocated] is a boolean. Is this possible? If so what is wrong with my code?
 
The problem is in the control references.Try this:

Private Sub Allocated_AfterUpdate()
If Me.Allocated = True Then
Me.Job = Forms![Jobs Entry]![Job]
End If
End Sub

HTH,
Nikos
 
You haven't actually specified what your problem is. In addition to what
Nikos has suggested, you probably need to put something in the Else side of
the If statement so that the value of Me.Job isn't set when Allocated is
False.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Nikos Yannacopoulos said:
The problem is in the control references.Try this:

Private Sub Allocated_AfterUpdate()
If Me.Allocated = True Then
Me.Job = Forms![Jobs Entry]![Job]
End If
End Sub

HTH,
Nikos

sleek said:
Private Sub Allocated_AfterUpdate()
If [Allocated] = True Then
[Job] = [Forms]![Jobs Entry]![Job]
End If
End Sub

Im trying to write a simple if statement, but cant get it to work, as
[Allocated] is a boolean. Is this possible? If so what is wrong with my code?
 
Doug,

I'm not following you. The way I understand the simple procedure I
suggested, Me.Job wouldn't be set if Allocated = False.What am I missing
here?

Thanks,
Nikos

Douglas J. Steele said:
You haven't actually specified what your problem is. In addition to what
Nikos has suggested, you probably need to put something in the Else side of
the If statement so that the value of Me.Job isn't set when Allocated is
False.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Nikos Yannacopoulos said:
The problem is in the control references.Try this:

Private Sub Allocated_AfterUpdate()
If Me.Allocated = True Then
Me.Job = Forms![Jobs Entry]![Job]
End If
End Sub

HTH,
Nikos

sleek said:
Private Sub Allocated_AfterUpdate()
If [Allocated] = True Then
[Job] = [Forms]![Jobs Entry]![Job]
End If
End Sub

Im trying to write a simple if statement, but cant get it to work, as
[Allocated] is a boolean. Is this possible? If so what is wrong with
my
code?
 
I suppose it depends on how the form is set up, but in general, the first
time you get a value of Allocated that's true, the Me.Job will get a value
assigned to it. That value will be used for subsequent entries, whether or
not Allocated is true.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Nikos Yannacopoulos said:
Doug,

I'm not following you. The way I understand the simple procedure I
suggested, Me.Job wouldn't be set if Allocated = False.What am I missing
here?

Thanks,
Nikos

Douglas J. Steele said:
You haven't actually specified what your problem is. In addition to what
Nikos has suggested, you probably need to put something in the Else side of
the If statement so that the value of Me.Job isn't set when Allocated is
False.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Nikos Yannacopoulos said:
The problem is in the control references.Try this:

Private Sub Allocated_AfterUpdate()
If Me.Allocated = True Then
Me.Job = Forms![Jobs Entry]![Job]
End If
End Sub

HTH,
Nikos

Private Sub Allocated_AfterUpdate()
If [Allocated] = True Then
[Job] = [Forms]![Jobs Entry]![Job]
End If
End Sub

Im trying to write a simple if statement, but cant get it to work, as
[Allocated] is a boolean. Is this possible? If so what is wrong with my
code?
 
Doug,

Thanks for this. Maybe I have misunderstood something, but I thought that
Sleek was trying to set the value of a control on a form (having just opened
it from another form, a control of which he's reading the value from), not
set the value of a global variable, which I understand is what you had in
mind, right?

Sleek, if you're still out there, would you please clarify?

Thank you both,
Nikos


My understanding was, though, that this would apply to assigning a value to
a global variable, not setting the value of a control on a form, which is
the case here.
Douglas J. Steele said:
I suppose it depends on how the form is set up, but in general, the first
time you get a value of Allocated that's true, the Me.Job will get a value
assigned to it. That value will be used for subsequent entries, whether or
not Allocated is true.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Nikos Yannacopoulos said:
Doug,

I'm not following you. The way I understand the simple procedure I
suggested, Me.Job wouldn't be set if Allocated = False.What am I missing
here?

Thanks,
Nikos

Douglas J. Steele said:
You haven't actually specified what your problem is. In addition to what
Nikos has suggested, you probably need to put something in the Else
side
of
the If statement so that the value of Me.Job isn't set when Allocated is
False.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



The problem is in the control references.Try this:

Private Sub Allocated_AfterUpdate()
If Me.Allocated = True Then
Me.Job = Forms![Jobs Entry]![Job]
End If
End Sub

HTH,
Nikos

Private Sub Allocated_AfterUpdate()
If [Allocated] = True Then
[Job] = [Forms]![Jobs Entry]![Job]
End If
End Sub

Im trying to write a simple if statement, but cant get it to work, as
[Allocated] is a boolean. Is this possible? If so what is wrong
with
my
 
Back
Top