Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stLinkCriteria and Null 1

Status
Not open for further replies.

ailyn

Programmer
Sep 15, 2005
108
BE
Hi!
I'm trying this to see if I need to make a new record or I just open the existing one:

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Proformas"
stLinkCriteria = "[Proformas_OrderId] = " & Me![OrderId]
If IsNull(stLinkCriteria) Then
DoCmd.OpenForm stDocName, , , , acFormAdd
Forms!Proformas.Form!ProformasOrderIdctrl = Me.OrderId
MsgBox "unexistant value"
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
MsgBox "exists"
End If

It always tries to open an existant record although there isn't, and I get an empty form Proformas with the msgBox 'exists'. Why isn't it getting if the stLinkCriteria exists? Should I filter it otherwise?

PS: tbl Proformas has the OrderId from tbl Orders and this command comes from the Orders form.
 
stLinkCriteria is never null, it's a string!

Why not:
Code:
If DCount("*","tblOrders","OrderId=" & Me![OrderId]) > 0 Then
' Exists - do exist stuff
Else
' Non-existent - so add stuff
End If
 
THANKS! It works!
That deserved a star. XD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top