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

Opening a From Macro Help 1

Status
Not open for further replies.

unisysce

MIS
Jan 30, 2008
8
US
Thanks for loooking.

I am writing a macro that will open a form. Here is what part of the macro says:
Forms![frmOpenEMC]![CallNo] = Forms![frmMainViewEMC]![ListOpen]

I need it to open the first Column on that list. What am I missing???
 
Is this what you're after?

Forms![frmOpenEMC]![CallNo] = Forms![frmMainViewEMC]![ListOpen].Column(0)

Paul
MS Access MVP 2007/2008
 
I tried it but it's giving me the following error:

Undefined function '[CallNo]=[Forms]![frmMainViewEMC]![ListDone].[Column]' in expression.

 
What exactly are you trying to accomplish? That code has nothing to do with opening a form; it is placing a value from one form to another. Is this really in a macro, or VBA?

Paul
MS Access MVP 2007/2008
 
i really dont know what I'm doing. I know bits and pieces from here and there.

I have a listbox with 2 columns(Date, CallNumber). I want to double click on a record and have it open another form (frmEMCOpen) to the corresponding record (CallNumber).

I modified the one you sent me and now it asks me for the CallNumber. When I plug it in manually, it opens the right record.

Thanks for your help pbaldy.
 
Well, the VBA code to open a second form to the record on the first would look like:

DoCmd.OpenForm "SecondFormName", , , "FieldName = " & Me.ControlName

Also, the column property is zero based, so you'd want a 1 for the second column. Try this

DoCmd.OpenForm "frmOpenEMC", , , "CallNo = " & Me.ListOpen.Column(1)

I'm guessing a little on which are the correct names. We also need to confirm where exactly you are; a macro or VBA code. We also need to make sure you aren't typing that directly into the properties window.

Paul
MS Access MVP 2007/2008
 
pbaldy,

I tried it but now it gives me runtime error2501. The OpenForm action was canceled. It is the right name. Does it matter that the ListOpen is based of a query?

Once again, thank you.
 
No, it shouldn't matter. What is the data type of CallNo in the table? If it's text, try this:

DoCmd.OpenForm "frmOpenEMC", , , "CallNo = '" & Me.ListOpen.Column(1) & "'"

Paul
MS Access MVP 2007/2008
 
YES, YES, YES, YES!!!!!!!!!

That was it. I had always been told that if you really didn't need to use numbers (for math)in db, to use text insted which is what I did. Technically it is a "number" but I'm not doing any math with it.

This is awsome for me. You have no idea.
 
Excellent! Glad we sorted it out. I would agree on things like phone numbers, zip codes, etc. Things like employee numbers or account numbers I store as numbers. My understanding is that numeric keys will perform better than text keys. I'm not saying it's wrong, and I wouldn't change it, just throwing out another thought.

Paul
MS Access MVP 2007/2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top