mainform - subform problem

  • Thread starter Thread starter Gina
  • Start date Start date
G

Gina

Hi

in my code for a garage frmWork is a subform of frmCar.
frmWork is based on a query, which takes as criteria frmCar.RegNum both are
linked via car registration number RegNum

RegNum and CustID are PK in the underlying tblCar
the easy part works fine

now, when a new car is added to an existing customer (or a new customer is
added together with a new car) I check whether the input in frmCar.RegNum is
valid.
therfore I wrote 2 (module) functions where first is counted the RegNum - if
is 0 - fine not already in db

if it is 1 then I check whether car is already registerd for that particular
customer - if 1 fine . (had to do this as I do the checking in the
before_update, after_update and the lost_focus event - user might click into
the RegNum field or pass it by via tab key)

problem is now that eventhough the number typed into the RegNum field is not
ok, the subform looks for the details of that car with the typed RegNum and
shows them.

1. how can I stop the frmWork from displaying the car's details when it's
not a correkt input (then I set it to carRegOK = false) ???
2. is it possible after my original setup of forms at all - criteria
field ???
3. am I using the right 3 events for the check of frmCar.RegNum field at
all ???

- well I have to do this check for not messing up the db!! :(
any help and idea highly appreciated

Gina
 
Gina, are you saying that all of your checking code works but now you're not
sure how to procede with stopping the execution of default execution of the
subform? If that is the problem, you can simply leave the subform without a
datasource or rowsource and leave it disabled until your code makes the
logical descision of how to procede.

After the logical checks have determined a correct course of execution,
write a line of code to set the properties of the subform object to produce
the desired actions at run time. It sounds like you have a subform which just
doesn't care about your logic, it's going to load anyways. It can't load
anything without a rowsource. In fact, you can even leave the subform object
looking to a generic dummy subform, then determine at run time between
differnt forms altogether to use as the subform; based on infinite scenerios.
No Databoject, no data.

Let me know if I'm even close here or if it sounds like a good Idea but
you're not sure how to implement, I have samples I can post for you
somewhere, if you like...
Rev.
 
Hi Rev.

Thank you very much for your answer ....!!
I've struggeld yesterday, the half day before yesterday and I am struggeling
on this today ....still
Gina, are you saying that all of your checking code works but now you're not
sure how to procede with stopping the execution of default execution of the
subform?

exactly that's the case
If that is the problem, you can simply leave the subform without a
datasource or rowsource and leave it disabled until your code makes the
logical descision of how to procede.

well .. it is bound to the query and so are all the fields ... could I
temporaily not bind them to a rowsource ?
After the logical checks have determined a correct course of execution,

well ... tat's a bit of a problem: if I determine a variable on code behind
form the frmCar should it then still be 'alive' when I enter a subform ???
write a line of code to set the properties of the subform object
the subform object - the frmWork in my case ??!! ?

sorry ... I am a bit puzzled ... as it sounds as if I have to change /
rewrite quite a few things .... the 'only' reason is that the subform
executes when it shouldn't
that hurts !!!
to produce the desired actions at run time. It sounds like you have a subform which just
doesn't care about your logic, it's going to load anyways. It can't load
anything without a rowsource.

would I set the rowsource to nothing ?
In fact, you can even leave the subform object
looking to a generic dummy subform,

what would that mean .... ???
then determine at run time between
differnt forms altogether to use as the subform; based on infinite scenerios.
No Databoject, no data.


Let me know if I'm even close here or if it sounds like a good Idea but
you're not sure how to implement,

yes I am not sure how to implement at all ....
I have samples I can post for you
somewhere, if you like...

yes, Rev .... it sounds like a very good idea and in fact probably the only
way ??? to solve the problem

Gina
 
All right Gina, as a wise man once told me, "Don't Spaz!")
This is why we just love Access so much... cause it's so easy! Right.

I can't really see your code from here. There may be one small thing you are
doing in the wrong order or something, but I can't see it from here. To
answer a couple of the questions below, the answer to "can you disable the
subform's rowsource temporarly?" is absolutely yes, I've done this in several
apps. I like to open my forms containing subforms that require user input,
rowsourceless. I often do this with listboxes and subforms just because I
don't want them accessible or showing name# and they always seem to be
showing leftover data from the previous use or something I don't like.
However, this methodology requires your code to get data directly from the
underlying query, which is not much different than getting it from your
subform because usually the names are the same and you are essentially doing
the same thing no matter what face you put on the data (Query By Example,
Recordset Objects, RecordsetClones, SQL Statements in a .TXT document, ADO,
DAO...ActiveXDOTNET_DLL blah blah blah) Whatever, if the data is in a table
with rows and colums, that's what your are accessing and querying. So
regardless of the interface, the syntax will be comprehensible to you because
you already understand the structure of the underlying data.... I'm running
out of breath...

Can you post your code here? or a ilustrative snippit that I can use to
produce similar results on my machine? If you don't want to post your code
here, you can send me your form with minimal sample data directly to:
EnterAccessTools @ Cox .Net (no spaces, no spam) and I would be glad to run
it through my debug process. The answer you seek is probably so simple and
obvious that once you see it you'll need a drink and want to hide your
propellar cap for a couple of days. Just kidding with ya... If sending a form
to me is an option for you, .Zip it up and send it over., that would be
easiest for me... As Jeff Spicolly Said after crashing that car in Fast Times
at Ridgemount High "I can fix it! I swear, my dad's a tv repairman! He has an
awsome set of tools..." I have an awsome set of tools :-)
Rev.
PS... I just associated my .NET password for MSDN Subscriptions and now
every time I respond to a post and it takes me more than five minutes to
write the response I get timed out and it takes me all the way back to >?????
some place where I can't find the post I was responding to. And it eats my
responses if I don't copy them to my clip board... that's why its taking some
time to respond
 
Hi Gina, I've been having email probs taking up about 2 hours of my morning,
that really sucks, but I'm on it... I'll let you know what I come up with
soon... Not sure what time it is where you're at, you're probably sleeping by
now... You may find a couple of repeat messages as my email is kind of
freaking out.
 
Back
Top