Somebody Please Help Me

U

UpRider

When "everything works perfectly", instead of making the control invisible,
make its dimensions 1x1 pixel. Problem solved. Everything works perfectly.

UpRider
 
J

John W. Vinson

When "everything works perfectly", instead of making the control invisible,
make its dimensions 1x1 pixel. Problem solved. Everything works perfectly.

Don't forget to set its Tabstop property to No as well.
 
B

BruceM

AccessVandal already wrote what I would have suggested. I generally search
using a combo box in the header, so I completely forgot that you are
searching from a dialog form. Another point is that you may find you need
to keep the dialog form open but hidden. In the main form's Close event you
could have:
DoCmd.Close acForm, "DialogFormName"

The Me prefix references the current form. It is not transferred when that
form closes. In any case, while the dialog form is open Me refers to it, so
Me.lstFirm (or Me!lstFirm) would refer to lstFrm in the dialog form. To
refer to another object, as suggested:

Dim frm as Form
Dim rst As DAO.Recordset
Dim lngSelect As Long

Set frm = Forms!YourFromName

'Check to see if no selection was made.
If IsNull(frm.lstFirm) Then
MsgBox "Make a selection or click Cancel", , "No Selection"
Exit Sub
End If

'Store the selection (firm ID number) in a variable.
lngSelect = frm.lstFirm

'Close the dialog form to switch back to the main form.
Me.Visible = False

'Find the selected record.
Set rst = frm.RecordsetClone
rst.FindFirst "aIDFirm = " & lngSelect

'Check the result
If rst.NoMatch Then
MsgBox "Record not found."
Else
frm.Bookmark = rst.Bookmark
End If

Rather than opening another form you could maybe have the list box in the
header, and make it visible when you click the command button. Or you could
place the list box in the form header and make that visible.

Me.FormHeader.Visible = True

or to toggle it:

Me.FormHeader.Visible = Not Me.FormHeader.Visible

In any case, you will probably want to hide it in the form's Current event.

Just another option to consider. Remember that when referencing one form or
report from code in another form you need to use the full Forms!FormName
reference.


oldblindpew said:
Thank you, BruceM.

I had already tried changing the bangs into dots, although I did not think
a) that I had it wrong, and b) that it would make any difference. It did
not
make any difference.

I followed your instructions and got the step-thru to work. Its funny my
reference book said nothing about having to insert a break point to force
the
execution into break mode. It just said put your cursor where you want
and
press F8 to begin.

Single stepping confirms that Set rst = Me.RecordsetClone generates the
error. "Me" refers to the dialog form initially, and when that is closed
the
firm form becomes the active form, "Me" should refer to it, but it isn't
working. "Me" has to be the object in the expression that is either
closed
or doesn't exist. Weird.
 
O

oldblindpew

Hallelujah! It's finally working! Thank you, Thank you, Thank you! There
is no pleasure so keen as the sudden cessation of great pain. No matter how
rank the piece of junk you're working on, once you get it fixed and running
you start to develop that warm glow. Now I can join the other Stepford Wives
who sing the praises of Access...Not. ;-)

Notice the solution involves hard-coding a form name into my procedure,
which means this procedure is now married to that one form. I had been using
the same procedure to find firms for several different forms. I now need to
either a) make duplicate copies of this procedure, each differing only with
regard to the form name, or b) find a way to pass the form name to the
procedure, or c) avoid opening a dialog form by putting list boxes in all my
forms, so that "Me" can be used to create recordset clones for differnt forms.

Thanks again for bearing with me through this.
 
B

BruceM

The first argument for OpenForm is the form name. After that there are
several others, including OpenArgs. OpenArgs is used to pass a value to
another form.

Dim strFormName as String
strFormName = Me.Form.Name

DoCmd.OpenForm "frmSearch", , , , , , strFormName

or to simplify if this is the only argument after the form name:

DoCmd.OpenForm "frmSearch", OpenArgs:=strFormName

Note that this code is exactly as it appears here. Do not substitute for
Form.Name or anything like that. The idea is that you are passing the name
of the calling form (the one from which you open the search form) to the
searchform. As long as the search form is open you can refer to its
OpenArgs value:

Instead of:

Set frm = Forms!YourFromName

try:

Set frm = Forms(strFormName)

The code up to that point:

Dim frm as Form
Dim rst As DAO.Recordset
Dim lngSelect As Long
Dim strArgs as String

strArgs = Me.OpenArgs

Set frm = Forms(strArgs)

The rest of the code is as before.

As a caveat, I will not have a chance to test this in your exact situation.
It should work, but I can't say I remember every detail, or that I have
explained it clearly. If it does not work you may do best to start another
thread, showing all of the relevant code you have so far. It would be
better to do it that way than to reference this thread. I've been taking
part in this thread and am starting to get a bit disoriented myself.

Note that frmSearch will retain the OpenArgs value as long as it (frmSearch)
is open. If you are using frmSearch from another form (Form2) you will need
to close frmSearch so you can pass the OpenArgs value from Form2 to
frmSearch; otherwise frmSeqrch will retain the original OpenArgs value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top