MarionD's Code (1 Viewer)

lscheer

Registered User.
Local time
Today, 21:26
Joined
Jan 20, 2000
Messages
185
In a post from a couple weeks ago, Marion posted this code/message:
Hi there

If you still need help - I usually use apply filter to do what you need.

You need to put an unbound control at the top of your form for a " dummy entry"

Your user enter the ptid in this field then in the after update event of the dummy control you add the code
docmd.applyfilter,"[ptid]=" & me.dummycontrol name

You can fancy this up by using an if statement eg.
x=dcount ("*",Tablename,"[ptid]=" & me.dummy)
if x > then 0 then 'if the record exists
docmd.applyfilter.........
else
docmd.gotorecord acnewrec
realptid.setfous
end if

this uses a count to ascertain if the record exists - if it does it filters it out and if it doesn't it prepares to add a new record.

Hope this helps

...when I tried to use it for this purpose, the "x=..." part at the beginning was highlighted and said "variable undefined" Any clues as to why?

Marion
 

Angello Pimental

Registered User.
Local time
Today, 21:26
Joined
May 9, 2001
Messages
92
I believe you need to define x, somthing like this:

Dim x as integer

put that at the top of the code

HTH
 

lscheer

Registered User.
Local time
Today, 21:26
Joined
Jan 20, 2000
Messages
185
Thanks, now the Compile error says "IIf (x>0)" Argument Not Optional. Here is what I have in my module. I'm not too VB literate, so any help is great. Thanks!

Private Sub DUMMY_AfterUpdate()
Dim x As Integer
x = DCount("*", [Participants Table Query], "[PART ID]=" & Me.DUMMY)
IIf (x > 0)
DoCmd.ApplyFilter ("[PART ID]=" & Me.DUMMY)
DoCmd.GoToRecord (acNewRec)
Real [PART ID].SetFocus
End If

End Sub
 

D-Fresh

Registered User.
Local time
Today, 21:26
Joined
Jun 6, 2000
Messages
225
IIF is a really more of a function call then a statement. The plain IF statement should be used here in your code, so just drop one of the I's and you'll be set.

Hope this helps.

Doug
 

lscheer

Registered User.
Local time
Today, 21:26
Joined
Jan 20, 2000
Messages
185
Thanks...Now, though, it just says Syntax Error for the "If (x>0)" part........
 

D-Fresh

Registered User.
Local time
Today, 21:26
Joined
Jun 6, 2000
Messages
225
oh yeah, you have to put a then statement on the end there... sorry about that..


if x>0 then
...
...
...
end if
 

lscheer

Registered User.
Local time
Today, 21:26
Joined
Jan 20, 2000
Messages
185
Ok...one more compile error, now at the ".setfocus" part saying "expected function or variable"....?

[This message has been edited by lscheer (edited 08-26-2001).]
 

lscheer

Registered User.
Local time
Today, 21:26
Joined
Jan 20, 2000
Messages
185
I'm hoping that after the long weekend, somebody might have some more insight for me...I really need to get this code squared away and working so that I can get my db fully functional. Thanks a lot!!!
 

Users who are viewing this thread

Top Bottom