dbTalk Databases Forums  

Form / Subform Problems loading Data

comp.database.ms-access comp.database.ms-access


Discuss Form / Subform Problems loading Data in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
nic
 
Posts: n/a

Default Form / Subform Problems loading Data - 01-29-2004 , 10:22 AM






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

Reply With Quote
  #2  
Old   
MazeMan
 
Posts: n/a

Default Re: Form / Subform Problems loading Data - 01-30-2004 , 07:55 AM






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" <nicfantis (AT) yahoo (DOT) co.uk> schreef in bericht
news:aa26ac1d.0401290822.269d80b6 (AT) posting (DOT) google.com...
Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.