473,547 Members | 2,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open form to specific record or create new record

2 New Member
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 27287
MMcCarthy
14,534 Recognized Expert Moderator MVP
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,564 Recognized Expert Moderator MVP
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 Recognized Expert Moderator MVP
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
1741
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 records from "available specs" (and several fields from each of those records).
4
4040
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 need to create one in frmRevisionHistory, and pass the PK (PK_Fees) on frmFeeInput to FK_Fees on the 2nd form.
2
6322
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 tables are indexed. So the user will pull up either one record or none. Here is my problem: I pass the form name through a tmpvariable and ther other...
3
3835
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 Datasheet View, the specific underlying record's Row... showing all columns Or selected columns. For a specific row's record ONLY, Or for all Xs (same...
4
3157
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 not there, they are to click a
4
13391
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 shows me one to several forms that are related to that serial #. Each form shows only a few select fields of that particular record. I would like to be...
3
10553
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 other one is Next button which i created to open another form "frmSummary" which displays back the records submitted. (i used the wizard to open form...
8
31366
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 single view. DoCmd.OpenForm "FRMBookingDetails", , " = " & Me.BookingID The form opens only on the first record only and never the chosen...
6
3050
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 temporary table. The record is also tagged with the name of the user who created it. What I'm trying to do is to force the form to open up and load this...
0
7703
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7463
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6032
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3493
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3473
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1923
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.