473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

From a form open another form to a particular record

I'm a NEWBIE!!!

I have two forms frmStudent and frmCourse. frmStudent has a field [MR#], from the frmStudent I would like to open frmCourse, select the desire course but as soon as I select the course, I want frmCourse to make sure it is using the same[MR#]. I noticed that if you make frmCourse a subform to frmStudent it automatically does it but I would like to make this action happen with a command button and not as a subform. Help!!! How would I do that? Thank you!!!!
Dec 9 '09 #1
5 1389
debasisdas
8,127 Expert 4TB
kindly post the code that you are working on.
Dec 11 '09 #2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.NewRecord Then
  3. [EmployeeID].Defaulty=Forms![Student]![EmployeeID]
  4. End If
  5. End Sub
Dec 11 '09 #3
patjones
931 Expert 512MB
Hi Cutepaloma -

I'm much more experienced with VBA, but I think the general concept I'm going to lay out should still be applicable. Suppose you have a button cmdGetCourse and text box txtEmployeeID on frmStudent. You can put all your code for opening frmCourse in the Click event for cmdGetCourse:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdGetCourse_Click()
  2.  
  3. If IsNull(Me.txtEmployeeID) Then
  4.      MsgBox "No employee ID present! Please try again..."
  5.      Exit Sub
  6. Else
  7.      DoCmd.OpenForm "frmCourse",acNormal,,,,,Me.txtEmployeeID
  8. EndIf
  9.  
  10. End Sub
  11.  

This is a very basic subroutine of course, but notice the last argument in the OpenForm command. Whatever you put in here will get passed to frmCourse as a parameter. In the module for frmCourse, you can access it using Me.OpenArgs (look at the help pages for more information about OpenArgs) - and use it for whatever purpose you need within the code for frmCourse. Like I mentioned before, the syntax in VB.NET may be a bit different, but the logic will still be the same I think.

Another option for you to consider is setting up a global variable that holds the employee ID. Since it's global you would be able to access the variable from any module in your project, including frmCourse.

Hope this helps.
Dec 11 '09 #4
OMG!!! It worked!!! Thank you. Thank you.
Dec 11 '09 #5
patjones
931 Expert 512MB
You're welcome. I'm happy to hear it. Just make sure you test the other branch of the IF statement...you should have some mechanism in place to trap the situation in case an ID is not present for some reason. You can also look at the help pages for MsgBox, because it takes many arguments besides the message string to make the box look more user friendly.
Dec 11 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Skully Matjas | last post by:
Thank you for getting back to me. I am very new at this so i didnot understand what you said, here i will give as much cetails as possible: 1) The combo box i am using is combox39 2) I imported...
7
by: DD | last post by:
Hi I want the user to be able to view all reports from a form either by way of a list box or dropdown or ?? any help please DD
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
1
by: Ian | last post by:
I want to open a form at a particular record, but I think I'm running into problems because the recordsource query is executing asynchronously. In the form's open event I use...
1
by: campbellbrian2001 | last post by:
I'm looking at the Access2003 Northwind Database Orders form uopn which I'm basing a similar form for my company's use. How can I take a particular record in the subform and open an actual edit...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
5
by: Nothing | last post by:
I have a search results form that is being displayed as a continous form. I want to double click the name and then using VBA select the different columns of information. For Example: Name ...
4
by: Leah Trahan | last post by:
I am new at Access, databases, AND posting threads (sorry). I have a subform that is a continuous form based on a tabular query. I enter a particular serial # (on the main form) and the subform...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
6
by: CJONES | last post by:
I have a main form and use a combo box to open a pop up form. The combo box lists customers and only one customer requires the fields that are found on the pop up form. I can get the form to pop...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.