dbTalk Databases Forums  

Re: Please help, must be simple

comp.databases.ms-access comp.databases.ms-access


Discuss Re: Please help, must be simple in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Larry Linson
 
Posts: n/a

Default Re: Please help, must be simple - 08-05-2003 , 04:26 PM






First, try naming the _Controls_ (text boxes) on your form a different name
than the underlying _Field_ in the Table or Query that is the Record Source
for a Form. For example, prefix them with "txt" and try the following:

If Len(Me.txtProposalSent) > 0 And Len(Me.txtProposalAccepted) > 0 Then
....

If that doesn't do what you want, then explain why you say that it is
"ProposalAccepted" with which you are having trouble. Please follow up or
clarify here in the newsgroup, not by e-mail. Thanks.

Larry Linson
Microsoft Access MVP


"Koen" <no (AT) spam (DOT) nl> wrote

Quote:
Hi all,

I am a newbie, struggling with this issue:

I have three fields on (the same form):

ProposalSent (Date field)
ProposalAccepted (Date field)
Status (Text field)

I want the following: Once I update the ProposalSent field, some logic
has to check if there is or isn't a date in the ProposalAccepted field.
If not, the Status field is changed to 'Waiting', else the Status field
is changed to 'In progress'.

I think when I attach the same logic to the AfterUpdate events of both
Date Fields I should succeed.



Private Sub ProposalSent_AfterUpdate()
If Me.ProposalSent <> "" And Me.ProposalAccepted = "" Then
Me.Status.Value = "4"
MsgBox "Status is changed to 'Waiting'"

Else
Me.Status.Value = "1"
MsgBox "Status is 'In progress'"

End If
End Sub


This doesn't work. The *Me.ProposalSent <> ""* part works, but there seem
to be some trouble with the *Me.ProposalAccepted = ""* part.

Who can help me?

Thanks.

Koen.



Reply With Quote
  #2  
Old   
Koen
 
Posts: n/a

Default Re: Please help, must be simple - 08-05-2003 , 04:52 PM






"Larry Linson" <larry.linson (AT) ntpcug (DOT) org> wrote in
news:hiVXa.4396$uw6.1120 (AT) nwrddc02 (DOT) gnilink.net:

Quote:
First, try naming the _Controls_ (text boxes) on your form a different
name than the underlying _Field_ in the Table or Query that is the
Record Source for a Form. For example, prefix them with "txt" and try
the following:

If Len(Me.txtProposalSent) > 0 And Len(Me.txtProposalAccepted)
0 Then
....

If that doesn't do what you want, then explain why you say that it is
"ProposalAccepted" with which you are having trouble. Please follow up
or clarify here in the newsgroup, not by e-mail. Thanks.

Larry Linson
Microsoft Access MVP


OK. I followed your advice. But the behaviour is still the same.

This isn't working (sample 1):

Private Sub txtProposalSent_AfterUpdate()
If Len(Me.txtProposalSent <> 0) And Len(Me.txtProposalSent = 0) Then
MsgBox "Because sent, but not accepted, the status should be Awaiting"
Else
MsgBox "Status: In progress"
End If
End Sub

And this is (sample 2) (but it is not what I want):

Private Sub txtProposalSent_AfterUpdate()
If Len(Me.txtProposalSent <> 0) Then
MsgBox "Because sent, but not accepted, the status should be AWAITING"
Else
MsgBox "In progress"
End If
End Sub


I wish I could explain why the *And Len(Me.txtProposalSent = 0)* part is
giving me trouble. But it is what I need: I only want to change the
status in case there is a value present in txtProposalSent without a
value present in txtProposalAccepted.

Sample 1 allows me to enter a value in txtProposalSent and the MsgBox "In
progress" pops up. This is wrong because it should check if there is a
value present in txtProposalAccepted and give the other message.

Sample 2 allows me to enter a value in txtProposalSent and the MsgBox
"Because sent, but not accepted, the status should be AWAITING" pops up.

I don't understand this. What am I doing wrong?

Regards, Koen


Reply With Quote
  #3  
Old   
Rick Brandt
 
Posts: n/a

Default Re: Please help, must be simple - 08-05-2003 , 04:56 PM



"Koen" <no (AT) spam (DOT) nl> wrote

Quote:
OK. I followed your advice. But the behaviour is still the same.

This isn't working (sample 1):

Private Sub txtProposalSent_AfterUpdate()
If Len(Me.txtProposalSent <> 0) And Len(Me.txtProposalSent = 0) Then
MsgBox "Because sent, but not accepted, the status should be Awaiting"
Else
MsgBox "Status: In progress"
End If
End Sub
Take a closer look at the first line of your If statement. Shouldn't those two
control names be different?




Reply With Quote
  #4  
Old   
Koen
 
Posts: n/a

Default Re: Please help, must be simple - 08-05-2003 , 05:00 PM



"Rick Brandt" <RBrandt (AT) Hunter (DOT) Com> wrote in
news:bgp95l$p4dv6$1 (AT) ID-98015 (DOT) news.uni-berlin.de:

Quote:
"Koen" <no (AT) spam (DOT) nl> wrote in message
news:Xns93CEF2E7D68D1Rubends (AT) 194 (DOT) 109.133.20...
OK. I followed your advice. But the behaviour is still the same.

This isn't working (sample 1):

Private Sub txtProposalSent_AfterUpdate()
If Len(Me.txtProposalSent <> 0) And Len(Me.txtProposalSent = 0) Then
MsgBox "Because sent, but not accepted, the status should be
Awaiting"
Else
MsgBox "Status: In progress"
End If
End Sub

Take a closer look at the first line of your If statement. Shouldn't
those two control names be different?


Sorry for this cut and paste error in my previous posting. In access I
did it right (see below), but it is not working (as I described in my
previous post).

Sample 1:

Private Sub txtProposalSent_AfterUpdate()
If Len(Me.txtProposalSent <> 0) And Len(Me.txtProposalAccepted = 0) Then
MsgBox "Because sent, but not accepted, the status should be AWAITING"
Else
MsgBox "In progress"
End If
End Sub


Reply With Quote
  #5  
Old   
Rick Brandt
 
Posts: n/a

Default Re: Please help, must be simple - 08-05-2003 , 05:45 PM



"Koen" <no (AT) spam (DOT) nl> wrote

Quote:
Sorry for this cut and paste error in my previous posting. In access I
did it right (see below), but it is not working (as I described in my
previous post).

Sample 1:

Private Sub txtProposalSent_AfterUpdate()
If Len(Me.txtProposalSent <> 0) And Len(Me.txtProposalSent = 0) Then
MsgBox "Because sent, but not accepted, the status should be AWAITING"
Else
MsgBox "In progress"
End If
End Sub
The Len() function does not return zero if the field is null. It returns null.

Try

Len(Nz(Me.txtProposalSent ,""))




Reply With Quote
  #6  
Old   
Kelly Groves
 
Posts: n/a

Default Re: Please help, must be simple - 08-05-2003 , 09:50 PM




"Koen" <no (AT) spam (DOT) nl> wrote

Quote:
Hi all,

I am a newbie, struggling with this issue:

I have three fields on (the same form):

ProposalSent (Date field)
ProposalAccepted (Date field)
Status (Text field)

I want the following: Once I update the ProposalSent field, some logic
has to check if there is or isn't a date in the ProposalAccepted field.
If not, the Status field is changed to 'Waiting', else the Status field
is changed to 'In progress'.

I think when I attach the same logic to the AfterUpdate events of both
Date Fields I should succeed.



Private Sub ProposalSent_AfterUpdate()
If Me.ProposalSent <> "" And Me.ProposalAccepted = "" Then
Me.Status.Value = "4"
MsgBox "Status is changed to 'Waiting'"

Else
Me.Status.Value = "1"
MsgBox "Status is 'In progress'"

End If
End Sub


This doesn't work. The *Me.ProposalSent <> ""* part works, but there seem
to be some trouble with the *Me.ProposalAccepted = ""* part.

Who can help me?

Thanks.

Koen.

Best help for newbies:
http://www.mvps.org/access/

Kelly Groves, MVP




Reply With Quote
  #7  
Old   
Koen
 
Posts: n/a

Default Thanks (was: Re: Please help, must be simple) - 08-06-2003 , 01:20 AM



Chuck Grimsby <c.grimsby (AT) worldnet (DOT) att.net.invalid> wrote in
news:mae0jvciob6jajkto4itque9ah1q3vpqs3 (AT) 4ax (DOT) com:

Quote:

Len(Me.txtProposalSent <> 0) should be:
(Len(Me.txtProposalSent.Value & "") > 0)

Len(Me.txtProposalAccepted = 0) Should be:
(Len(Me.txtProposalAccepted.Value & "") = 0)



Thanks Chuck! It works!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.