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

Form missing 1

Status
Not open for further replies.

jake7363

Technical User
May 31, 2006
56
Hello,
I am trying to write code to a module, but the module will not perform, I believe, because the form I am referrign to is not listed in the Microsoft Access Class Objects List.
It is a valid form, in a single record format. The form works fine, but is just not listed. Is there any way I can add it manually?

Thanks in advance,
Jake
 
Hi!

To refer to a form in code it not only needs to exist in the database it also needs to be open, unless opening it is what you are trying to do. Let us see the code and maybe we can help more.

If your database really doesn't recognize the form then I would delete it and start over.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
It's not that the database doesn't see the form, it does. I use it for many other things. It is just this module. I have used the same method in other databases and no problem.

I have another project going on, and I will post the code tomorrow.

Thanks..
 
Most likely the reason it is not visible in the list is because it does not have a module associated with. Check the properties of "has module". However, this should not be a problem.

To refer to a form in code it not only needs to exist in the database it also needs to be open
This is a false statement. To use the Forms collection it has to be open, but not the class object. To refernce "frmOne" precede with "form_"

Set myForm = form_frmOne
Set myReport = report_rptOne

By referring to it this way instead of the forms collection you get the benefit of intelisense.
 
OK, per the requests, here is the code:
Function ViewFlow1Instance()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmFlow1Col"

stLinkCriteria = "[Autonumber]=" & Forms!frmFlow1Col![Autonumber]

DoCmd.OpenForm stDocName, , , stLinkCriteria

End Function

Also, I did set the properties for the form to indicate "Has Module", but this made no difference.

As I said, this code has worked in another file, but I can seem to pinpoint what I am not getting on this one. Help!
 
1) Minor point. The above should be a sub routine not a function. Functions return values.
2)What happens when you call the code
Nothing?
Error message?
3) If nothing happens whenever you call code, always debug it to see that it is really executing.
Add a message box or a debug.print. ex:
...
DoCmd.OpenForm stDocName, , , stLinkCriteria
Msgbox "Form " stDocName & " opened with ID " & Forms!frmFlow1Col![Autonumber]

4) This does not make any sense.
stLinkCriteria = "[Autonumber]=" & Forms!frmFlow1Col![Autonumber]

You are trying to open a form "frmFlow1Col" so I assume it is not yet open. Then you are trying to open it to the [Autonumber] that is in "frmFlow1Col", the form you are trying to open. You probably mean the [autoNumber] from some other form besides the one you are trying to open. Procedurally that does not make sense. You can reference properties on closed forms, but not values in fiels because they do not exist.
 
Because my knowledge is lacking, I have no response, other than to restate what that it works in other applications.

The code was obtained by using the button wizard to open a single form to the same record indicated in a continuous form. That is the code that is written by Access. I simply adapted it so I could use a macro. When it worked, then I copied the code into the new file's module and changed the control names.

The "Autonumber" fields are the actual field names from the matched fields.

I hear that this doesn't make sense, but this is the only time it hasn't worked for me.

If there is a better way to accomplish my goal, I am interested.

Thanks,
Joe
 
Sorry - forgot - there is an error, that simply states "Action Failed" but give no error description or error code, refferrinf to the macro name.
 
When it worked, then I copied the code into the new file's module and changed the control names.
You obviously did not change the control names. What is the name of the form that you call this code from? It is not "frmFlow1Col". That would not make sense.

Where do you actually call this code? You have a function, but what event calls it. ex:

private sub cmdButton1_click()
viewFlow1Instance
end sub

How about using the wizard from the form you are calling the code from? Although your code worked before, you did not cut and paste and make the necessary changes correctly.
 
er..sorry...but it IS "frmFlow1Col"

I am using a toolbar button to call a macro (Run Code), which calls the module - precisely the manner I have previously used successfully.

Your assumptions may seem valid to you, but there is not that much to what I did; I went over it a few times before I posted.

 
Here is what makes no sense.

You have from "frmFlow1Col" open in single form view to a record with a given autonumber. Now you want to re-open "frmFlow1Col" to the same autonumber. In other words you are trying to do nothing. What do you really want to do?
 
I understand what you are asking.
Let me see if I can explain it clearly.

The currently opened form is "frmFlow1"(Continuous). While in frmFlow1, I select a record. I click the toolbar item referencing the macro to Open "frmFlow1Col"(Single). The "Autonumber" is the common field, haveing the same name which Access references to get the exact record in the Single form that was selcted in the Continuous form.

Does that help clarify?
 
Hi!

That does clarify it. Change this line:

stLinkCriteria = "[Autonumber]=" & Forms!frmFlow1Col![Autonumber]

to

stLinkCriteria = "[Autonumber]=" & Forms!frmFlow1![Autonumber]

That should give you what you want.

MajP, thanks for the information on referencing forms and reports. Is that new in later versions?

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
That did the trick! I knew better, but just didn't see it!!

Thanks to all!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top