By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,773 Members | 2,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,773 IT Pros & Developers. It's quick & easy.

Form / Subform Problems loading Data

P: n/a
nic
Hi

I am currently having problems getting two forms to behave the way I
want. I have two tables Student and Application, and their respective
forms. (Tables)Student has StudentID (PK) & an ApplicationID. And
Application has ApplicationID as its primary key.

With the main Form being the Student_Details form, I have a Button
which loads the Application Form. The way I want it to behave is when
the Load_AppForm button is clicked the following occurs; if an
applicationID exists in the student table then it loads the relevant
Application Details in the Application_Details form. Otherwise if the
Student table has no ApplicationID (ie, currently null, a new student)
then the Application Form will load to a new record, and then when all
data has been inputted here the ApplicationID is passed back to the
Student_Details form, and hence saved in the Student Table.

The following VB code within the Load_AppForm_Button_Click routine
doesn't quite work...and know that I will also need code behind the
Application Form as well.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Application_Details"

If Not IsNull([Forms]![Student_Details]![S_ApplicationID_txt])
Then
stLinkCriteria =
"[Forms]![Student_Details]![S_ApplicationID_txt]=" &
Me![ApplicationID_txt]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm "Application_Details"
End If

Any advise would be greatly appreciated.

Thanks nic
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nic,

I don't want to be rude, but if there is a 1:1 relation between a student
and an application, why don't you create a single table which contains all
data? If you don't have to split a table don't.
Another solution might be to keep the student form and to drag a
subform-control into it which has to refer to the application form. This
will handle the relational issues automatically. One major drawback is that
you have make some adjustments in both tables. You have to drop the
ApplicationID attribute in the student-table and add the StudentID attribute
to the application-table. Before you go any further, I think it is a good
idea to take a closer look at the subform-control documentation. This
control offers a lot of advantages in cases like this but it will take some
time to understand what it is doing.

Good luck!

"nic" <ni*******@yahoo.co.uk> schreef in bericht
news:aa**************************@posting.google.c om...
Hi

I am currently having problems getting two forms to behave the way I
want. I have two tables Student and Application, and their respective
forms. (Tables)Student has StudentID (PK) & an ApplicationID. And
Application has ApplicationID as its primary key.

With the main Form being the Student_Details form, I have a Button
which loads the Application Form. The way I want it to behave is when
the Load_AppForm button is clicked the following occurs; if an
applicationID exists in the student table then it loads the relevant
Application Details in the Application_Details form. Otherwise if the
Student table has no ApplicationID (ie, currently null, a new student)
then the Application Form will load to a new record, and then when all
data has been inputted here the ApplicationID is passed back to the
Student_Details form, and hence saved in the Student Table.

The following VB code within the Load_AppForm_Button_Click routine
doesn't quite work...and know that I will also need code behind the
Application Form as well.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Application_Details"

If Not IsNull([Forms]![Student_Details]![S_ApplicationID_txt])
Then
stLinkCriteria =
"[Forms]![Student_Details]![S_ApplicationID_txt]=" &
Me![ApplicationID_txt]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm "Application_Details"
End If

Any advise would be greatly appreciated.

Thanks nic

Nov 12 '05 #2

P: n/a
Thanks for your comments. I originally started out with StudentID in
the application table. Turns out it would have been too much of a head
ache the way I was going. I am still going to keep the 2 tables, I know
that I don't have to, but I will. Almost have it sussed, but should I
have further problems, the you may see another posting.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.