How to tell if a field has a value

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

I would like to do the following however I'm not sure how to code if a value
already exists in VB? Can you please take a look at this?

Private Sub Form_Current()
If Me![Case Worker].Value = True Then
Else

Me![Case Worker].Value = CurrentUser
End If

End Sub
 
If you want to set CaseWorker to CurrentUser as long as it doesn't already
have a value you want:

If IsNull(Me![Case Worker]) Then
Me![Case Worker] = CurrentUser
End If

The Value property contains the current value of the field. There is no
property to tell you whether it has been set or not (as far as I know). It's
also the default property, which is why I left it out. One thing you have to
be careful with - if the field is set to " " or "", IsNull will return false.
A Null value is different than the null string "" and is also different from
a blank value of " ". If the field can only have a Null value or a non-zero
string length then you don't have to worry about "" and " ".
 
Hi Jim, Works like a charm, you are so smart. Where is Novi, in Detroit?

Jim Burke in Novi said:
If you want to set CaseWorker to CurrentUser as long as it doesn't already
have a value you want:

If IsNull(Me![Case Worker]) Then
Me![Case Worker] = CurrentUser
End If

The Value property contains the current value of the field. There is no
property to tell you whether it has been set or not (as far as I know). It's
also the default property, which is why I left it out. One thing you have to
be careful with - if the field is set to " " or "", IsNull will return false.
A Null value is different than the null string "" and is also different from
a blank value of " ". If the field can only have a Null value or a non-zero
string length then you don't have to worry about "" and " ".

Emma said:
I would like to do the following however I'm not sure how to code if a value
already exists in VB? Can you please take a look at this?

Private Sub Form_Current()
If Me![Case Worker].Value = True Then
Else

Me![Case Worker].Value = CurrentUser
End If

End Sub
 
I see that Jim has already answered your question. However, I have a
question for you. Each time the current user arrives on a record without a
case worker, the case worker logged in will be assigned as the case worker.
Is this what you want?
 
Just a bit west of Detroit.

Emma said:
Hi Jim, Works like a charm, you are so smart. Where is Novi, in Detroit?

Jim Burke in Novi said:
If you want to set CaseWorker to CurrentUser as long as it doesn't already
have a value you want:

If IsNull(Me![Case Worker]) Then
Me![Case Worker] = CurrentUser
End If

The Value property contains the current value of the field. There is no
property to tell you whether it has been set or not (as far as I know). It's
also the default property, which is why I left it out. One thing you have to
be careful with - if the field is set to " " or "", IsNull will return false.
A Null value is different than the null string "" and is also different from
a blank value of " ". If the field can only have a Null value or a non-zero
string length then you don't have to worry about "" and " ".

Emma said:
I would like to do the following however I'm not sure how to code if a value
already exists in VB? Can you please take a look at this?

Private Sub Form_Current()
If Me![Case Worker].Value = True Then
Else

Me![Case Worker].Value = CurrentUser
End If

End Sub
 
Yes exactly

Allan V. Pimble said:
I see that Jim has already answered your question. However, I have a
question for you. Each time the current user arrives on a record without a
case worker, the case worker logged in will be assigned as the case worker.
Is this what you want?


Emma said:
I would like to do the following however I'm not sure how to code if a value
already exists in VB? Can you please take a look at this?

Private Sub Form_Current()
If Me![Case Worker].Value = True Then
Else

Me![Case Worker].Value = CurrentUser
End If

End Sub
 
Oh I forgot to mention it's a drop down list if they want to change users.

Allan V. Pimble said:
I see that Jim has already answered your question. However, I have a
question for you. Each time the current user arrives on a record without a
case worker, the case worker logged in will be assigned as the case worker.
Is this what you want?


Emma said:
I would like to do the following however I'm not sure how to code if a value
already exists in VB? Can you please take a look at this?

Private Sub Form_Current()
If Me![Case Worker].Value = True Then
Else

Me![Case Worker].Value = CurrentUser
End If

End Sub
 
Back
Top