stLinkCriteria -- nulls ???

A

Anne

Hi...in hopes of enlightenment...

I open a form (popup) from a form as an AfterUpdate
Event. The main, as well as the popup forms each contain
a field "ClientID", although the one on the popup is not
visible.

My dilemma: The popup opens, linked, as it should when
there is data and also when there is not. I wish to open
the form only when there is data, that is, no blank form
opening.

I have tried many ways and cannot see the solution.

Can someone advise? See code below.

Thanks,
Anne

*** pertinent existing code follows ***

stDocName = "frm2V Job"
stLinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
A

Albert D. Kallal

For sure, you example code assues that clientid is a text field.

Anway, just go:

if isnull(me!ClientID) = false then

stDocName = "frm2V Job"
stLinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
end if
 
A

Anne

Thanks for replying. I cut and pasted and I still get
the same results -- a blank form for no data, populated
form for data. Yes, ClientID is text, but the
AfterUpdate event fires via a combo box selection. Does
that matter?

Help!
Anne
 
N

Noma-Gcina Mtshontshi

Hi Anne,
Instead of the isnull function - try

if me!ClientID > "" false then
<open the form based on cri>
end if

Noma-G
-----Original Message-----
Thanks for replying. I cut and pasted and I still get
the same results -- a blank form for no data, populated
form for data. Yes, ClientID is text, but the
AfterUpdate event fires via a combo box selection. Does
that matter?

Help!
Anne

-----Original Message-----
For sure, you example code assues that clientid is a text field.

Anway, just go:

if isnull(me!ClientID) = false then

stDocName = "frm2V Job"
stLinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
end if



--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


.
.
 
B

Bruce M. Thompson

Try changing:

.... to ...

If Len(Me!ClientID & "") > 0 Then

.... and ...
stLinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"

.... to ...

stLinkCriteria = "[ClientID]=" & """" & Me![ClientID] & """"

If all else fails, you could check to see if the opened form contains records
and, if not, close the form:

'*****
If Len(Me!ClientID & "") > 0 Then
stDocName = "frm2V Job"
stLinkCriteria = "[ClientID]=" & """" & Me![ClientID] & """"
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Forms(stDocName).RecordsetClone.Recordcount = 0 then
DoCmd.Close acForm, stDocName
End If
End If
'*****
 
A

Anne

All else DID fail, but that last try using Len did work.

Thanks so much Bruce and to the rest for your help.

Anne



-----Original Message-----
Try changing:

.... to ...

If Len(Me!ClientID & "") > 0 Then

.... and ...
stLinkCriteria = "[ClientID]=" & "'" & Me!
[ClientID] & "'"

.... to ...

stLinkCriteria = "[ClientID]=" & """" & Me! [ClientID] & """"

If all else fails, you could check to see if the opened form contains records
and, if not, close the form:

'*****
If Len(Me!ClientID & "") > 0 Then
stDocName = "frm2V Job"
stLinkCriteria = "[ClientID]=" & """" & Me![ClientID] & """"
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Forms(stDocName).RecordsetClone.Recordcount = 0 then
DoCmd.Close acForm, stDocName
End If
End If
'*****

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 

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


Top