Open a form and pass a parameter

I have a main form displayere list of employees.
I would like to open a second form to display the details of a selected 
employee. How can I do that?

One way I am thinking of is pass the employee number as argument when open 
the second form.

5/25/2007 3:41:25 AM
access.forms 6864 articles. 1 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 53

On Fri, 25 May 2007 13:41:25 +1000, Alan T wrote:

> I have a main form displayere list of employees.
> I would like to open a second form to display the details of a selected 
> employee. How can I do that?
> One way I am thinking of is pass the employee number as argument when open 
> the second form.

You don't need to pass the second form the employee number.
All you need do is open the second form (from the already open first
form) using the where argument of the DoCmd.OpenForm method.

Assuming the [EmployeeID] datatype is Number:
DoCmd.OpenForm "Form2", , , "[EmplyeeID] = " & Me![EmployeeID]

Form2 will open showing the records of the employee selected on Form1.

Look up the OpenForm method in VBA help.
Please respond only to this newsgroup.
I do not reply to personal e-mail
5/25/2007 4:28:49 AM

Similar Artilces:

No Data on Form Open
I have the following code on a cmdButton Dim strwhere As String strwhere = "[tbl_Reports].[FltPhase] = '" & Me![cboPhase] & "'" DoCmd.OpenForm "frm_MainView", acNormal, , strwhere DoCmd.Close acForm, "frm_SearchPhase" I would like to display a message "No data qualifies" and not open the form. Not sure what the If statement should read. -- Teach me to fish! Thanks for the help. Pax, M Hi, you can check recordset count on form's open event, and cancel it: if Me.Recordset.RecordCount =0 then Canc...

Reports not opening
The reports created in a MS Access database are not opening. Also the icon to open a new report in design view is not working either. I think it something related to the settings, but I can quite figure it out. I tried to put the security level in Low but it did not work.Any help is appreciated. This is almost always due to either not having a default printer defined in the Windows Control Panel or an old printer driver. -- Duane Hookom Microsoft Access MVP If I have helped you, please help me by donating to UCP "Toly" wrote: ...

Form Appears Blank in Read Only .mdb
I have an mdb file that is located in a folder on our network where only I have write permissions. The mdb file has one form that views data from a linked table in another mdb file. When other users open the mdb file located in the read only directory, the message pops up "The database "*.mdb" is read-only. You won't be able to save changes made to data or object definitions in this database." This is fine, they don't need to save any changes. But when the form loads it is totally blank. How can I resolve this? Thanks, Graham Sounds like the form's DataE...

in Outlook2007 inbox and calander opens simultaneously
Dear Friends, When i open Outlook 2007 Client first it opens inbox and also seperate window for calander simultaneously. One more issue is that subject line comes in message box nits <> wrote: > When i open Outlook 2007 Client first it opens inbox and also seperate > window for calander simultaneously. Close the Calendar window first and then when you close the Inbox window, use File>Exit. Outlook should remember you had only one window open when you close and reopen only that window. > One more issue is that subject line comes in mes...

Can macro/userform run depending on HOW workbook is opened?
I'd like to show a userform (and/or run a macro) when I open my Template Wizard database workbook...but NOT have it run when Excel opens it in the background to copy new records or update existing ones...any way to do this? tm If you put your code to show the form in Auto_open() (in a general module), then that'll run when the workbook is opened manually. If you open the workbook via code, it won't run (unless you run it explicitly, see RunAutoMacros in VBA's help for more info). Alternatively, you could put your code behind ThisWorkbook (workbook_open). This code will run...

Opening a query with a filter in Access 2007
Since under Access 2007 reports can no longer be exported to Excel, I'm attempting to open the query that the report is based on so that I can export the query to Excel. I'm wondering, though, about the best way to open the query since I need to apply a filter. It was easy enough to do in the OpenReport call by using the WhereCondition parameter, but OpenQuery has no such parameter. What is the best way to filter a query through code? Thanks, Carl Rapson A fairly simple workaround is to save the query you want to use for exporting. Then write its SQL property before you do t...

Excel not opening
Hi, When I double click Excell icon from the desktop, it opens excell without the default new sheet. when I double click any excell file from explorer, then excell and the file opens normally. Why excell is behaving like this? Pls help. Thanks. -- Athar Sagri Hi, Look at the icon properties and remove the switches such as "/e" or "/embedded" after "Excel.exe". HTH Daniel > Hi, > > When I double click Excell icon from the desktop, it opens excell without > the default new sheet. when I double click any excell file from explorer, > then exce...

money 2005 crashes every time I try to open an account
This happens with only one account I have. Its a checking account with online banking at keybank. Other online features work fine. Whenever I try to open the account I get an error message the money must be restarted. I have tried using the salvage utility and it does not find anything wrong. I have also tried reinstalling money. I still get the same error. My guess is that there is something wrong with the "data" in that account. Has anyone else had a similar problem? Any ideas of what to try so that I can fix this. Its somewhat urgent in that I can't send any of my onli...

Failure to open data files in Access 2000 on a XP machine
Hi Everyone, I had a Win98 machine on which I successfully opened and ran several datbase files in Access 2000. I now have a Win XP machine and after loading Office 2000 Premium on it I cannot open imported/exported data files from my old PC. It is driving my nuts. I feel I have tried everything but am probably missing something easy. When I try to repair the programme it is coming up with an error message for 4 .dll files (msolap, msmdcube, msmdgdrv and msolapui), it says failed to register. Please help. ...

Other Program Windows Keep Opening
I don't know how to remedy this problem. One of the computers in our office tends to open other program windows at random. Do you know what might cause this to happen. It seems to have an eradic cursor. Thanks for any suggestions you can make. ------------------------------------------------ ~~ Message posted from ~~ View and post usenet messages directly from Tools Option General Delete anythign in the box labeled Alternative startup directory "Fran" <> wrote in message news:Fra...

XML cannot be opened, try again, opens?
Greetings all, my first post to microsoft.public.excel. I have created about 30 xml spreadsheets. To create the sheets I saved a workbook as XML. I removed the "ss:ExpandedRowCount=". Choppped the XML file into a header & footer & my application supplies from <row> to </row> in the middle. Most of the files load okay but about 1 in ten comes up with a 'Cannot open XML' message from Office Assistant. The thing is, I go back to File Explorer, press enter to load the same file & it loads just fine into Excel. Im running Excel 2003 ( SP2 o...

CRM 4.0 form background color
Hi all! Does anyone know how to change the backgroud color of a contact form from the OnLoad event? Thanks for your help! Harry Answered in the developer newsgroup. -- Michael H�hne, Microsoft Dynamics CRM MVP CRM Blog: ---------------------------------------------------------- "Harry" <> schrieb im Newsbeitrag > Hi all! > > Does anyone know how to change the backgroud color of a contact form from > the OnLoad event? > > Than...

Moving from a form to a Nested Subform elsewhere on the form
I have tried umpteen different ways to do this, but cannot get my head around the complex syntax... I double-click on a form control and want to go to a 2nd Subform elsewhere on the Mainform. My Mainform is called: 'frm_Runs' My 1st 'target' Subform is called: 'frm_Street_Joiner_Main' My ultimate target Subform2 is called: 'frm_Street_Joiner_Sub' My ultimate control on Subform2 is called: [Joiner_Title_ID] How do I get there? The code I have below just goes to the [Joiner_Title_ID] control that is on my 'departure' form Forms!frm_Runs!frm_Street_...

Opening Publisher #4
Morning All, I work for a company that has got a load of lisenced office disks One of them is publisher, I have installed this before and never had any problems I recently had to format my PC, and when I tried to install publisher ( which worked fine ), then run it ( this is where I had the problem ), it is asking for a product key. I have never had to put a product key in before so why is it asking now It is only asking for the product key when you run the program. Not when you install it The company hasn't got a product key for this disk, but we have got one for office XP. (Publisher i...

Outlook 2000 won't open #2
Hi All I have MS Outlook 2000. When I click to launch it simply hangs up and I have to end using task manager. This is the first time I have had this occur to me but it is happening every start now. I have run new virus defs and windows update. Also, where does outlook store mail on the HDD? Many Thanks David Same thing happened to me. I had to re-install windows and then Outlook. As far as your messages, search for the .PST file. Good luck! Frank >-----Original Message----- >Hi All > >I have MS Outlook 2000. When I click to launch it simply >hangs up and I have...

Hyperlink to open new window?
I've created a simple Excel file that I use as a project menu. Each cell in the first column contains the name of a project and a hyperlink to the file containing that project. This works great for opening non-Excel project files. But when I click on a cell hyperlinked to an Excel project file, Excel closes my "Project Menu" file and opens the new project file in the same window where the project menu had been displayed. This is a bummer because most of my project files are Excel files. Then, the next time I need to access my project menu, I have to first manually reopen the...

Opening POS aslo opens Internet explorer in the background
Hi, has anyone encountered this problem? Every time I open POS, Internet explorer opens up in the background with MSN page. I cannot minimize or quit the application. I do not see the application listed in the task bar when I press Ctrl+Alt+Del buttons. Can anyone out there suggest a fix Hit the "ESC" key -- Mobitech Lady Amy Luby CEO, Mobitech Microsoft Certified Partner 402.330.0707 "JD" <> wrote in message > Hi, > > has anyone encountered...

WMP 12 Problem
I am operating on Windows 7. I have WMP 12.0.7600.16415. Everytime I play a video and close out the program I cannot re-open WMP again without rebooting the computer. Any ideas on how to correct this problem? What's the file type of these videos (AVI, WMV...)? If it's a file type that WMP doesn't support by default, which codec did you install to play it? Did you install any codec packs? WMP probably keeps running in the background after closing. When you restart WMP again, it immediately exits because it thinks that it's still running. To force WMP to close...

How do you recover a parameter?
Hello, I would like to execute an excel file, for example, with a file name file.xls zz.txt And afterwards, in that file, I would like to recover the name zz.txt. Could you please help me? Thanks. Dave, I'm not sure what you mean by "execute" the Excel file, or "recover the name." It sounds as though you want to make a txt file from the xls file. If so, you'll need to open it in Excel, then do File - Save As, with the file type set to txt. -- Earl Kiosterud ----------------------------------------------------------------------- &...

Loop with form
I have a form containing a label and an unbound control. I want to put the form in a loop that will allow the label box to change values and allow the user to enter a response in the control. I have the following code created: DoCmd.OpenForm "Data Entry 2", , acNormal For N = 0 To UBound(DeptArray) Forms![Data Entry 2].[LabelText].Caption = DeptArray(N, 1) Forms![Data Entry 2].Refresh Forms![Data Entry 2].[RespAnswer].SetFocus Next N This code works except for the fact that the process does not stop to allow the user to provide a res...

2003 docs opened in 2007
every time I open a powerpoint document that was saved as a 2003 version in 2007, the fonts are always messed up -- To the point that the document is almost unreadable. be above the actual cursor and are difficult (at best) to edit and correct... my office is still half on 2003 half on 2007 so this is creating some issues... is this something that is happening for others or am I doing something wrong? (or both :) ) is there a quick fix? nevermind... found advice on print driver and changed default to my other printer. fixed it immediately. "Memphus01" wrote:...

open workbook on same worksheet
Hi, Can anybody advise how I can get my workbook to automaticaly default to a certain worksheet once opened, ie when the workbooked is opened it will always default to the 'welcome' worksheet. thanks ps I'm a novice - so go easy Excel opens workbooks with the same sheet active as when the workbook was saved. The only way around that is to use a macro to switch sheets when the workbook opens. Of course this requires that the user not disable macros. Open the VBE and select the ThisWorkbook module. Paste this code in, changing Sheet1 to your sheet: Private Sub Workbook_Ope...

"message opened"
Is there any way to disable the exchange 2003 server to send "message opened" and "message delivery" mail out on the internet? //RO In Exchange 2000 it was possible, but you needed to write your own SMTP sink. I don't know if the feature is allready added to exchange 2003, but you might want to take a look at the following site: "Scotty44" <> wrote in message news:OPKD97EZEHA.3432@TK2MSFTNGP10.phx.gbl... > Is there any way to disable the exchange 2003 server to send "mes...

Open File IF Not Opened
Goodmorning! I was looking for someone who could tell me how I could make a Macro Appliction open files only when there not opened. When a file is allready opened it should be left at alone. When a file is being opened, this file should be granted the opportunity to update it's pivot tables and carry out any external links. I hope someone has the answer! Thanks in advance! Here's some code that might help. It tests whether a file is open: if it is it activates it, otherwise it opens the file. If IsWindowOpen(lStr_FileName) Then Windows(lStr_FileName).Activate ...

How to set form caption / text?
I use MFC Visual C++ 4.2. I am developing an application with main window and a few childs window. How to set each child window text / caption everytime I call DoModal? If I set "Entry Form" then the window I call will displayed with "Entry Form" caption. Thank you. You can use SetWindowText to set it. For a dialog, you should do it any time after its created(IOW, not in constructor). OnInitDialog and after is fine. -- Ajay "Landon" <> wrote in message >I ...