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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with my brain and logic!

Status
Not open for further replies.

ChrisTheAncient

Technical User
Dec 22, 2002
169
GB

I am developing a database in Access XP, based on NWinds, to monitor sales for some goodies I want to sell. So far I've got it working fine.

In the NWinds example, they used a date picking (form) system for a report that works well - for me. The report sets a public boolean variable to state whether the report is in the Open event. If the report is in this event, the date picker will work.

If a user tries to open the date picker form in isolation, trying to use the form creates a user message.

If Not Reports![Report1].blnOpening1 Then Err.Raise 0

Exit_OK_Click:
Exit Sub

Err_OK_Click:
retValue3 = MsgBox("To use this form, you must be in a report preview or design view.", vbOKOnly, "Whoops!!!")
Resume Exit_OK_Click


So far, so good (for me)!

The trouble is, I want to use this same date picker for a couple of other reports - Report2 and Report3 - as well! These other reports have the public variables blnOpening2 and blnOpening3.

Whatever syntax I seem to try and use to modify the above code to use any of the three reports ends up telling me, "To use this form, you must be in a report preview or design view."

I've been going round in circles for a couple of hours now trying to break my logic loop and my personal "Ctrl+Break" ain't helping!

What should the syntax be, p-l-e-a-s-e?

TIA

Chris





*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
I would have to say that I would create a function:

function CheckOpening(booOpening) returning a boolean value.

pass Reports![Report1].blnOpening1
or Reports![Report1].blnOpening2
or Reports![Report1].blnOpening3

check the value of the boolean passed in if its false then return false, if its true return true.

and use this function in place of

If Not Reports![Report1].blnOpening1 Then Err.Raise 0

like this:

if not CheckOpening(Reports![Report1].blnOpening1) then Err.Raise 0

then you can use it again when checking for blOpening2 and blOpening3.

Sorry I can't give you more explict code, but I don't do Access coding, all mine is in Delphi! but the principals are all the same!

HTH

Leslie

 

Hi Leslie.

Hmmm... I've never had a go with Delphi!

I think I can see what you mean. I shall try a couple of ways of looking at that and see if I can get my brain cell round that route. But I'm no that much of an Access programmer either. That's why I'm stuck.

Will try and report back.

Keeping the thread running to see if there are even more ideas.

Chris


*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Search forum705 (Access VBA), you should find plenty of examples there of how to set up function and call them.

Leslie
 

Hi again Leslie

I've spotted why I'm having problems! Simple really. If a report is not open, it cannot pass the blnOpening and the error that is really trying to be presented is to the effect that there is no report open.

Now I've got that into my thick skull, I can make progress (later - other odds and ends to do first now!).

Many thanks for the help and effort.

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top