Further explanation...repost

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,

I am having some troubles figuring this one out.

I have an application that has to be in english and french. To accomodate this i have a form which the user clicks english or french. then all other forms and reports will open in the appropriate language.

Now, i want to interchange several query recordsources for a single report, based on which form is open at the time the report was requested. I tried an if form visible then....but it didn't work. I got an error that said the form could not be found. I also recieved the following function but i don't see where the recordsource is being introduced. Can anyone help me?

Function FormExists(FormularName As String) As Boolean
Dim f As Form
Dim Gefunden As Boolean
Dim index As Integer

Gefunden = False
index = 0
While (Not Gefunden And index < Forms.Count)
Set f = Forms(index)
If f.FormName = FormularName Then
Gefunden = True
End If
index = index + 1
Wend
FormExists = Gefunden

End Function
 
the code you posted just tests to see if a particular form is open or not.
rather than continue down that path, i can offer another solution which may
be simpler.
if i understand you correctly, you want to set a report's RecordSource at
runtime, based on the name of the form that's currently open. i am assuming
you are opening the report from the form, by clicking a command button or
whatever. is both assumptions are true, here's one solution:

open a standard module (in the database window's Modules tab). add a public
variable, as

Public frmName As String

in the form's event that opens the report, add the following line of code
*before* the line that opens the report, as

frmName = Me.Name
DoCmd.OpenReport ....

in the report's OnOpen event, add the following procedure, as

Private Sub Report_Open(Cancel As Integer)

Dim strQry As String

Select Case frmName
Case "MyFirstFormName"
strQry = "MyFirstQueryName"
Case "MySecondFormName"
strQry = "MySecondQueryName"
Case Else
MsgBox "no form name provided"
End Select

frmName = ""
Me.RecordSource = strQry

End Sub

in the Select Case statement, substitute your form and query names, of
course. only two cases are listed, but you can add as many more case
statements as you need, repeating the two lines

Case "FormName"
strQry = "QueryName"

make sure the Case Else statement is the last one.
in re-reading your post, i'm not sure if you have two forms open at the same
time? and are opening the report from one form, but want its' RecordSource
based on which "other" form is open? if this is correct, the solution can
still work but will require a little tweaking. post back if you need these
"tweak" details.

hth


Carlee said:
Hello everyone,

I am having some troubles figuring this one out.

I have an application that has to be in english and french. To accomodate
this i have a form which the user clicks english or french. then all other
forms and reports will open in the appropriate language.
Now, i want to interchange several query recordsources for a single
report, based on which form is open at the time the report was requested. I
tried an if form visible then....but it didn't work. I got an error that
said the form could not be found. I also recieved the following function
but i don't see where the recordsource is being introduced. Can anyone help
me?
 
hi there

got this part working. Question for you. I have another form that is always open which determines what language to use. It is an option group. If option =1 then the english is used, if =2 then french. How can i incorporate this into what you have shown me?

example: if frame =1 and form1 is open then open reportA using QueryA - or
if frame =2 and form1 is open then open reportA using Query

etc. There are about 6 or 7 conditions that determine which report to open, using which language and which query.
 
A problem has come up

I tried the code you used and for the first form it worked great. I went to the second form and the code runs, skipping the case statement want to use and going to the case else statment which is my error handle. The report opens, but with a Name? on each of my fields. Any ideas

Carlee
 
double check the spelling of the form name you entered in that particular
Case statement - if it's misspelled, the system won't match it to the actual
form name value saved in the variable frmName.
once this issue is solved for you, i'll address your other posted question
re two forms - unless someone else answers it for you in the meantime. :)


Carlee said:
A problem has come up.

I tried the code you used and for the first form it worked great. I went
to the second form and the code runs, skipping the case statement want to
use and going to the case else statment which is my error handle. The
report opens, but with a Name? on each of my fields. Any ideas?
 
Hello there

problem solved on both fronts! I used an if statement and then put the case statement for each if to accomodate the need for english and french

Many thanks for your hel

Regards

Carlee
 
Back
Top