473,396 Members | 1,655 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.

open form to specific record or create new record

2
I have a database that I am using to store student data. There are two tables and two forms to display the data:

Tables
tbStudent
tbRE

Forms
fmStudent
fmRE

tbStudent stores basic student data, while tbRE stores specific academic data for some, but not all, students. The two tables are linked through the student ID number(stStuID), which is the key in tbStudent.

I would like to create a command button in fmStudent that opens fmRE, but to the record of the student currently displayed in fmStudent. Aside from opening fmRE to a specific record, I am also curious about what happens if a student does not have a record in fmRE. Could I have the command open fmRE to a blank record if the student doesn't have a record, so the user can enter the data to create one?

I have not used VBA very much so I am new to this level of design. I've seen some responses to this type of question, but I'm not sure how to get started with the coding.

I am using Access 2003 on Windows XP.

Thanks!
Nov 13 '06 #1
3 27258
MMcCarthy
14,534 Expert Mod 8TB
The easiest way to do this is to use a subform on your form that is the fmRE. Bind it using the stStuID field. This will display the records for students who have them and a blank record where there is no record available.

If you try to open another form you will have problems with the ones that haven't any records. For future reference the code would be:

DoCmd.OpenForm "fmRE", , , "[stStuID]=" & Me.stStuID

I have a database that I am using to store student data. There are two tables and two forms to display the data:

Tables
tbStudent
tbRE

Forms
fmStudent
fmRE

tbStudent stores basic student data, while tbRE stores specific academic data for some, but not all, students. The two tables are linked through the student ID number(stStuID), which is the key in tbStudent.

I would like to create a command button in fmStudent that opens fmRE, but to the record of the student currently displayed in fmStudent. Aside from opening fmRE to a specific record, I am also curious about what happens if a student does not have a record in fmRE. Could I have the command open fmRE to a blank record if the student doesn't have a record, so the user can enter the data to create one?

I have not used VBA very much so I am new to this level of design. I've seen some responses to this type of question, but I'm not sure how to get started with the coding.

I am using Access 2003 on Windows XP.

Thanks!
Nov 13 '06 #2
NeoPa
32,556 Expert Mod 16PB
DoCmd.OpenForm "fmRE", , , "[stStuID]=" & Me.stStuID
Or if, as I suspect, the st of stStuID stands for string, then you must add quotes around the variable in your code thus :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "fmRE", , , "[stStuID]='" & Me.stStuID & "'"
Nov 13 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Or if, as I suspect, the st of stStuID stands for string, then you must add quotes around the variable in your code thus :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "fmRE", , , "[stStuID]='" & Me.stStuID & "'"
Good call.

I just assumed that ID would be a number. I have to stop doing that.



Mary
Nov 13 '06 #4

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

Similar topics

1
by: Robin S. | last post by:
More clueless newbie questions... Table 1: "available specs" Table 2: "classes" A single form shows a single record from the table "classes". Each record in "classes" may contain several...
4
by: amywolfie | last post by:
I've been trying to do something for about 3 days – I get close, but not 100%. I am trying to: Open frmRevisionHistory from a button on frmFeeInput. If there is NO RELATED RECORD, then I...
2
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying...
3
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in...
4
by: piscogirl | last post by:
Hi all, Here's my case: I have a form: Event Form and a subform: AttendanceSubForm The user selects a name (from a Person Table) on the subform to register for the event. If the name is...
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...
3
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The...
8
reginaldmerritt
by: reginaldmerritt | last post by:
Hi, I'm using the following code to open a form on a specific record. I have a form displaying records in a list which then allows users to click onto the record to open it up in a new form in a...
6
by: Adam Tippelt | last post by:
I've got a form that allows users to "save the current record to drafts" if they haven't finished writing all the data for that record. This saves it in it's current state, which puts it in a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.