Clean recordset on open form (1 Viewer)

Carl_R

Registered User.
Local time
Today, 10:49
Joined
Aug 16, 2002
Messages
82
ok, so I have a form with an unbound combox in the header and two bound text boxes in the detail section of the form.

I am simply using the form to lookup data (in the two textboxes) based on selections made in the combobox.

All working fine except, when I open the form the recordset is loaded so I immediately see data (the first record) in the text boxes.

What I would like to do is open the form and see nothing in the text boxes (so, a clean recordset). I can then perform my search via the combobox and voila!, the textboxes are populated.

I know it's something simple but perhaps I can't accomplish this with form properties and need to go down the code path "me.recordset....??????"

Any ideas?
 

yhchen

Registered User.
Local time
Today, 01:49
Joined
Jul 6, 2008
Messages
63
write a simple micro:

GoToRecord

object type: choose form
object name: choose your form name
record: choose new

save the macro

go to your form, go to design view, choose form property, under event submenu, on click choose the macro you just created.

it should work fine....
 

Carl_R

Registered User.
Local time
Today, 10:49
Joined
Aug 16, 2002
Messages
82
Played with it but it simply opens a new record for input (you have to open the form first). I actually don't want to create a new record. Just search records already there.
 

LPurvis

AWF VIP
Local time
Today, 09:49
Joined
Jun 16, 2008
Messages
1,269
You'd likely give yourself either a totally unbound form to begin with (remove the Recordsource property of the form) or set it to be an empty result set.
e.g.
Instead of a recordsource of "tblTable" or "SELECT * FROM tblTable" just
""SELECT * FROM tblTable WHERE 1=0"
If you disallowed Additions then you'd see no controls at all then.
If you remove the source altogether then you're going to get controls with "#Name" displayed until you assign a source.

Then you can assign the source once you've selected an entry from the combo.
If it's purely for lookups (and you're using Acc2002 or newer) you could even use the single recordset from the combo control to source the form upon each selection.
 

missinglinq

AWF VIP
Local time
Today, 04:49
Joined
Jun 20, 2003
Messages
6,420
Played with it but it simply opens a new record for input (you have to open the form first). I actually don't want to create a new record. Just search records already there.

yhchen's suggestion will give you a blank record, which is what you requested, and unless you actually enter data, the new record won't be created. When you use your search and move to another record, the "blank record will be dumped.
 

Carl_R

Registered User.
Local time
Today, 10:49
Joined
Aug 16, 2002
Messages
82
I get you but when I select a name from my combobox, the record is created. I've found a workaround.
 

Users who are viewing this thread

Top Bottom