Connecting Tech Pros Worldwide Forums | Help | Site Map

Form / Subform Problems loading Data

nic
Guest
 
Posts: n/a
#1: Nov 12 '05
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

MazeMan
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Form / Subform Problems loading Data


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@yahoo.co.uk> schreef in bericht
news:aa26ac1d.0401290822.269d80b6@posting.google.c om...[color=blue]
> 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[/color]


Nicholas Fantis
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Form / Subform Problems loading Data


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!
Closed Thread


Similar Microsoft Access / VBA bytes