Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / December 2004



Tip: Looking for answers? Try searching our database.

populate subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smk23 - 30 Dec 2004 11:51 GMT
How would I populate a subform within an unbound MS Access (2003) form? The
main form populates fine with an ADO connection. But I need to pass a
parameter to the subform and then populate that as well. Any suggestions or
source of information?

Thanks a lot.
Signature

sam

Jan Hyde - 30 Dec 2004 12:12 GMT
"smk23" <smk23@discussions.microsoft.com>'s wild thoughts
were released on Thu, 30 Dec 2004 03:51:02 -0800 bearing the
following fruit:

>How would I populate a subform within an unbound MS Access (2003) form? The
>main form populates fine with an ADO connection. But I need to pass a
>parameter to the subform and then populate that as well. Any suggestions or
>source of information?

Why should populating another form be any different than
populating the first form? Perhaps some more information
might help us undersand the problem.

Jan Hyde (VB MVP)

Signature

How do you catch a bra?
Set a boobie trap. (Rodney Lee)

[Abolish the TV License - http://www.tvlicensing.biz/]

smk23 - 30 Dec 2004 14:11 GMT
I knew this was going to be too "general" but wasn't sure how to state my
question. Basically, I'm an Access person. A programmer was developing a form
for me using vba and ado with unbound controls. I have some knowledge of
populating unbound forms, but not a lot.

In Access, I'm used to just setting the Parent and child relationship and I
get the records I want. I just need to know how to do the same thing in this
setting.

I'd love for my programmer to finish this, but he moved to another firm,
leaving me in a lurch. I've spent days and weeks looking for simple answers
before, and I know this is simple for you folks. If you can link me to an
article, that's fine.
Thank you.

> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
> were released on Thu, 30 Dec 2004 03:51:02 -0800 bearing the
[quoted text clipped - 10 lines]
>
> Jan Hyde (VB MVP)
Jan Hyde - 30 Dec 2004 14:49 GMT
"smk23" <smk23@discussions.microsoft.com>'s wild thoughts
were released on Thu, 30 Dec 2004 06:11:03 -0800 bearing the
following fruit:

>I knew this was going to be too "general" but wasn't sure how to state my
>question. Basically, I'm an Access person. A programmer was developing a form
[quoted text clipped - 10 lines]
>article, that's fine.
>Thank you.

Typically when not working with bound control (very sensible
IMO) you create a connection (ADODB.Connection) to the
database and store the data retrieved from the database in a
recordset (ADODB.Recordset)

Does this sound familiar given the code you've looked at?

J

>> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
>> were released on Thu, 30 Dec 2004 03:51:02 -0800 bearing the
[quoted text clipped - 10 lines]
>>
>> Jan Hyde (VB MVP)

Jan Hyde (VB MVP)

Signature

"Henry the Eighth weighed over 300 pounds!" Tom stated unthinkingly.
(Stan Kegel)

[Abolish the TV License - http://www.tvlicensing.biz/]

smk23 - 30 Dec 2004 15:45 GMT
Yes, there is code to create the connection and retrieve the recordset. I
passed a variable (ClientID) to the module on the subform, but it's not
executing anything. I appears to be pulling a recordset of the entire db, not
selected records.

Here is the line creating the recordset:

   .brSelectCommandText = "SELECT ocm.* FROM " & _
       "dbo.OccMain ocm " & _
       "WHERE ocm.ClientID = " & mlngClientID

oops! now I see that I haven't passed the value of mlngClientID. How do I do
that?

Sam

> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
> were released on Thu, 30 Dec 2004 06:11:03 -0800 bearing the
[quoted text clipped - 40 lines]
>
> Jan Hyde (VB MVP)
Jan Hyde - 30 Dec 2004 16:05 GMT
"smk23" <smk23@discussions.microsoft.com>'s wild thoughts
were released on Thu, 30 Dec 2004 07:45:10 -0800 bearing the
following fruit:

>Yes, there is code to create the connection and retrieve the recordset. I
>passed a variable (ClientID) to the module on the subform, but it's not
[quoted text clipped - 6 lines]
>        "dbo.OccMain ocm " & _
>        "WHERE ocm.ClientID = " & mlngClientID

ClientID is probably unique, and so the recordset would
contain one record containing all fields (pcm.*) for that
client ID

>oops! now I see that I haven't passed the value of mlngClientID. How do I do
>that?

Um? Yes you have, according to that SQL above. Assuming that
the passed in ClientId is stored in the variable
mlngClientID.

Are you familar with the fields on the table 'OccMain'?
Do you know how to access these fields in the recordset?

J

>Sam
>
[quoted text clipped - 42 lines]
>>
>> Jan Hyde (VB MVP)

Jan Hyde (VB MVP)

Signature

The convicted architect discovered that prison walls were not made to scale. (Gary Hallock)

[Abolish the TV License - http://www.tvlicensing.biz/]

smk23 - 30 Dec 2004 15:59 GMT
I passed the value of ClientID and now I get a syntax error stating invalid
use of null. It appears that this is executing before the parent form
populates.
so close....... !
Sam

> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
> were released on Thu, 30 Dec 2004 06:11:03 -0800 bearing the
[quoted text clipped - 40 lines]
>
> Jan Hyde (VB MVP)
Jan Hyde - 30 Dec 2004 16:37 GMT
"smk23" <smk23@discussions.microsoft.com>'s wild thoughts
were released on Thu, 30 Dec 2004 07:59:04 -0800 bearing the
following fruit:

>I passed the value of ClientID and now I get a syntax error stating invalid
>use of null. It appears that this is executing before the parent form
>populates.
>so close....... !
> Sam

Post the line that gives the syntax error.

J

>> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
>> were released on Thu, 30 Dec 2004 06:11:03 -0800 bearing the
[quoted text clipped - 40 lines]
>>
>> Jan Hyde (VB MVP)

Jan Hyde (VB MVP)

Signature

Belong: To take your time (Art. Moger)

[Abolish the TV License - http://www.tvlicensing.biz/]

smk23 - 30 Dec 2004 17:05 GMT
This code is on the subform. I get a error pointing to the 2nd line with
message "invalid use of null" when opening the main form.

Private Sub Form_Open(Cancel As Integer)

mlngAilmentID = Me.Parent.AilmentID

> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
> were released on Thu, 30 Dec 2004 07:59:04 -0800 bearing the
[quoted text clipped - 56 lines]
>
> Jan Hyde (VB MVP)
Jan Hyde - 30 Dec 2004 17:10 GMT
"smk23" <smk23@discussions.microsoft.com>'s wild thoughts
were released on Thu, 30 Dec 2004 09:05:02 -0800 bearing the
following fruit:

>This code is on the subform. I get a error pointing to the 2nd line with
>message "invalid use of null" when opening the main form.
>
>Private Sub Form_Open(Cancel As Integer)
>
>mlngAilmentID = Me.Parent.AilmentID

Yuk. I'd change the code to pass ID through to the child
form.

AilmentID cannot be a long value then since a long cannot be
NULL.

>> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
>> were released on Thu, 30 Dec 2004 07:59:04 -0800 bearing the
[quoted text clipped - 56 lines]
>>
>> Jan Hyde (VB MVP)

Jan Hyde (VB MVP)

Signature

When the TV repairman got married, the reception was excellent.
(Pun of the Day)

[Abolish the TV License - http://www.tvlicensing.biz/]

smk23 - 30 Dec 2004 17:45 GMT
You'd take this code off the subform and put what in the main form? This is
my doing, the programmer didn't write the line below.

> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
> were released on Thu, 30 Dec 2004 09:05:02 -0800 bearing the
[quoted text clipped - 75 lines]
>
> Jan Hyde (VB MVP)
Jan Hyde - 31 Dec 2004 09:01 GMT
"smk23" <smk23@discussions.microsoft.com>'s wild thoughts
were released on Thu, 30 Dec 2004 09:45:04 -0800 bearing the
following fruit:

>You'd take this code off the subform and put what in the main form? This is
>my doing, the programmer didn't write the line below.

I'd give the Subform I ClientID property, in the main form I
would set my subform.ClientID = ClientID if you get my
meaning, anyway that's another issue. You need to look at

Me.Parent.AilmentID

Because this must be returning a null value.

>> "smk23" <smk23@discussions.microsoft.com>'s wild thoughts
>> were released on Thu, 30 Dec 2004 09:05:02 -0800 bearing the
[quoted text clipped - 75 lines]
>>
>> Jan Hyde (VB MVP)

Jan Hyde (VB MVP)

Signature

Justice:  Only frozen water (Jan Hyde)

[Abolish the TV License - http://www.tvlicensing.biz/]

Veign - 30 Dec 2004 15:29 GMT
When you say SubForm are you referring to an Access type of form? (I think
Access has a special form called a SubForm)..  If yes, then your questions
would be better posted in the Access programming newsgroup.

Signature

Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

> I knew this was going to be too "general" but wasn't sure how to state my
> question. Basically, I'm an Access person. A programmer was developing a form
[quoted text clipped - 25 lines]
> >
> > Jan Hyde (VB MVP)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.