423,850 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,850 IT Pros & Developers. It's quick & easy.

2 if then else statements or 2 of the same forms and reports? you choose! lol

P: n/a
I have a search form that is great. I have modified it in such a way,
that when search results come up I can bring it back to a useful spot,
say an entry form or a report.

Here is my lemon ( hoping someone can help me make lemonade!)

I have this form implemented with my Candidate entry form, as a find.
click the find button, search, subsearch form shows results, click
select on the needed record, and the search form closes, the entry form
now at that record.

I previously had this as the report form, choose a candidate report
from the reports menu, and get this search form, find your candidate,
hit select, and report with that candidate comes up.

Now the challenge. My first clumsy thought is to make 2 search forms
and subforms, and 2 candidate reports ( since I have a quick candidate
report button on the entry form, for easy access - this is important
because the report gets its candid parameter from the entry form in
this instance, from report menu it would get it from the search form
result chosen.)

Then I thought that a lot of programmers would yell at me for something
like this, because I would be duplicating forms and reports because of
dual points of entry on the one form and report.

I am trying, then, to use the one search form to act as both the entry
search form and the report search form. I also want the candidate
report to work from the entry form interface and the report menu
interface.

Now the code I am working with is on the button in the subform of the
search form. I need to add some code to what already works. Basically
right now it says to bring back the current record to the candidate
entry form, and if the candidate type is one of a few then to show that
page that only shows under that condition. Because of that, I don't
know how to put an encompassing if else statement outside of that.

I need to add that if the candidate entry form is open ( in background
when being used for finding entry) then to bring record back to entry
form (and with that if candidate is one of a few types show that page
too), else to bring that candidate to the candidate report, and preview
it....

here is the code for the bring back to entry form:

code:
Private Sub CmdGetCand_Click()
On Error GoTo Err_CmdGetCand_Click
Dim Rs As DAO.Recordset

Set Rs = Forms!frmCandidateEntry.RecordsetClone

Rs.FindFirst "[CandID] = " & Me!CandID

Forms!frmCandidateEntry.Bookmark = Rs.Bookmark

Set Rs = Nothing

If Forms!frmCandidateEntry!cmbCandidateType = 2 Or
Forms!frmCandidateEntry!cmbCandidateType = 4 Or
Forms!frmCandidateEntry!cmbCandidateType = 5 Or
Forms!frmCandidateEntry!cmbCandidateType = 9 Or
Forms!frmCandidateEntry!cmbCandidateType = 10 Or
Forms!frmCandidateEntry!cmbCandidateType = 12 Then

Forms!frmCandidateEntry!TbCandSubs.Pages.Item(0).V isible = True

Else: Forms!frmCandidateEntry!PgAttInfo.Visible = False
End If

DoCmd.Close acForm, "frmFindCandidate"
Exit_CmdGetCand_Click:
Exit Sub
Err_CmdGetCand_Click:
MsgBox Err.Description
Resume Exit_CmdGetCand_Click
End Sub
----

I would think to add something in the beginning like

if forms!frmCandidateEntry.isopen then...
and then at the end put

else
docmd.previewreport rptCandidatereport

Just thinking that with the if then else statement in the middle that
the code would get confused when to endif on what endif. catch my
drift?

-------------------------------------

I will worry about fixing the reports conditional criteria after this
is fixed.

-- that would be whether it should get the candid from the entry form
or the search form.
Thanks for any who can help!

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Looks like a mountain out of a molehill

A simple comboBox or List box Combo1 on your candidate form with the
RowSource something like
SELECT CandidateName, CandidateID FROM Candidates ORDER BY CandidateName;

2 Columns, Width 3,0 Bound Column 2
Private Combo1_AfterUpdate

DoCmd.GotoControl CanDidateID
DoCmd.FindRecord Combo1
End Sub

Select the candidate from the combo box and you get the correct record.

Have an option group with various option buttons to print different reports.

If you want to hide different fields, do this on the OnCurrent of the form

Private Sub Form_Current()
If CandidateType = 2 Or CandidateType = 4 ............
xxxx.Visible = False
else
xxxx.Visible = True
end if

End Sub
"misscrf" <mi*****@yahoo.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
I have a search form that is great. I have modified it in such a way,
that when search results come up I can bring it back to a useful spot,
say an entry form or a report.

Here is my lemon ( hoping someone can help me make lemonade!)

I have this form implemented with my Candidate entry form, as a find.
click the find button, search, subsearch form shows results, click
select on the needed record, and the search form closes, the entry form
now at that record.

I previously had this as the report form, choose a candidate report
from the reports menu, and get this search form, find your candidate,
hit select, and report with that candidate comes up.

Now the challenge. My first clumsy thought is to make 2 search forms
and subforms, and 2 candidate reports ( since I have a quick candidate
report button on the entry form, for easy access - this is important
because the report gets its candid parameter from the entry form in
this instance, from report menu it would get it from the search form
result chosen.)

Then I thought that a lot of programmers would yell at me for something
like this, because I would be duplicating forms and reports because of
dual points of entry on the one form and report.

I am trying, then, to use the one search form to act as both the entry
search form and the report search form. I also want the candidate
report to work from the entry form interface and the report menu
interface.

Now the code I am working with is on the button in the subform of the
search form. I need to add some code to what already works. Basically
right now it says to bring back the current record to the candidate
entry form, and if the candidate type is one of a few then to show that
page that only shows under that condition. Because of that, I don't
know how to put an encompassing if else statement outside of that.

I need to add that if the candidate entry form is open ( in background
when being used for finding entry) then to bring record back to entry
form (and with that if candidate is one of a few types show that page
too), else to bring that candidate to the candidate report, and preview
it....

here is the code for the bring back to entry form:

code:
Private Sub CmdGetCand_Click()
On Error GoTo Err_CmdGetCand_Click
Dim Rs As DAO.Recordset

Set Rs = Forms!frmCandidateEntry.RecordsetClone

Rs.FindFirst "[CandID] = " & Me!CandID

Forms!frmCandidateEntry.Bookmark = Rs.Bookmark

Set Rs = Nothing

If Forms!frmCandidateEntry!cmbCandidateType = 2 Or
Forms!frmCandidateEntry!cmbCandidateType = 4 Or
Forms!frmCandidateEntry!cmbCandidateType = 5 Or
Forms!frmCandidateEntry!cmbCandidateType = 9 Or
Forms!frmCandidateEntry!cmbCandidateType = 10 Or
Forms!frmCandidateEntry!cmbCandidateType = 12 Then

Forms!frmCandidateEntry!TbCandSubs.Pages.Item(0).V isible = True

Else: Forms!frmCandidateEntry!PgAttInfo.Visible = False
End If

DoCmd.Close acForm, "frmFindCandidate"
Exit_CmdGetCand_Click:
Exit Sub
Err_CmdGetCand_Click:
MsgBox Err.Description
Resume Exit_CmdGetCand_Click
End Sub
----

I would think to add something in the beginning like

if forms!frmCandidateEntry.isopen then...
and then at the end put

else
docmd.previewreport rptCandidatereport

Just thinking that with the if then else statement in the middle that
the code would get confused when to endif on what endif. catch my
drift?

-------------------------------------

I will worry about fixing the reports conditional criteria after this
is fixed.

-- that would be whether it should get the candid from the entry form
or the search form.
Thanks for any who can help!

Nov 13 '05 #2

P: n/a

I think that you are on the right path, but there seems to be other
factors that I still need to take care of here. I have been told by the
future users that they need to be able to search for candidates, for
entry and reporting. A common reason is that a partner in the firm may
come to them and say "remember that candidate that went to Harvard?" if
that is all the info that they have, or they are only given 1 piece of
info, then they need a full search form.

My search form is unbound, and the subform with results is bound to a
query which has all fields a person might want to search on.

I like the idea of a combo box, but also, the reason for a candidate
report button on the entry form is not for printing. They usually
wouldn't want to waste paper or take the time to pick up a print. a
report is an easy way to see all of a candidate's info in one place, and
quickly close it. They can also then choose to print or pdf and email
to anyone ie the partner requesting the info.

Also, even with this method, I still need to take care of the criteria
on the backend of the report. I am not used to using code for a report,
so I even though I can imagine what it would be, I am not sure where i
would put it.

I have the report ( which has a bunch of subreports; that shouldn't
matter) and it is bound by the query builder.

I would think that I would do something like

if frmfindcandidate.isopen then
candid = candid
else
candid = forms!frmcandidateentry!candid
end if

something like that.

Anyway. I really want to figure this out from the perspective of this:

How does one use 1 form and 1 report in multiple places, controlling
where it grabs and places stuff based on how it was activated etc.

Thanks for the ideas. I will look at the app again on Monday to see
what I may be able to reconsider from your advice. It does make some
sense. I think I wasn't expecting to hear that my plan was overkill,
because I see programmers use these methods so often.

misscrf

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.