Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 10th, 2003, 10:22 PM
smilegloria smilegloria is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 26 smilegloria User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Get the current subform value inside a form

Hi All,

I have created a form called [Stock Reserved Activation]. Inside this form, it contains a subform called [Child0]. This subform shows all the records in a table called [Stock Transaction]. This table contains a field [RefNo].

What I want to do is when the user scroll to the specific record in the subform and click a button [Detail Update], then another form will be opened to show the corresponding record with the same [RefNo] as in the subform. How can I get the [RefNo] in the subform and pass it to the other form?

Thanks!

Rgds,
Gloria

Reply With Quote
  #2  
Old December 11th, 2003, 06:28 AM
TBÁrpi's Avatar
TBÁrpi TBÁrpi is offline
Lazy User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Hungary, Europe
Posts: 337 TBÁrpi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 5 m 5 sec
Reputation Power: 5
Send a message via MSN to TBÁrpi Send a message via Yahoo to TBÁrpi Send a message via Skype to TBÁrpi
Gloria,

You have two options:

1.
Using WhereCondition argument of OpenForm statement.

include the following code into your Click or DblClick event handler of the subform's field (the convention is DblClick):

DoCmd.OpenForm [form_name], , , [where_condition]

where [form_name] is the name of the form you wish to open, and [where_condition] is a string expression that filters the opening form.
WhereCondition argument is just like a WHERE clause of an SQL statement, but without the WHERE keyword.

2.
Using OpenArgs optional argument of OpenForm statement.
In this argument you can pass any value to an opening form.
To do this, use:
DoCmd.OpenForm [form_name], , , , , , [openargs]
where [openargs] is any value or a variable storing the value you wish to pass to the openng form. This can be the control containing RefNo.

Then, when the form is opening, use this in OnOpen event handler to find the record (if RefNo is numeric):

'****************
If Not IsNull(OpenArgs) Then
Me.RecordsetClone.FindFirst "[RefNo]=" & OpenArgs
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
'****************

If RefNo is a string, use:
'****************
If Not IsNull(OpenArgs) Then
Me.RecordsetClone.FindFirst "[RefNo]='" & OpenArgs & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
'****************

I hope this makes sense.
__________________
BRegs,
TBÁrpi
"I can only show you the door. You're the one who has to walk through it."

Reply With Quote
  #3  
Old December 11th, 2003, 08:23 PM
smilegloria smilegloria is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 26 smilegloria User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi TBÁrpi,

I found another solution myself and seems it works! In the form that contains the subform, there is a [Update Detail] button. When this button is clicked, I write the following event:

Private Sub Detail_Update_Click()

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "ReservedDetail"
strLinkCriteria = "RefNo = [forms]![Stock Reserved Activation]![Child0]![RefNo]"
DoCmd.OpenForm strDocName, , , strLinkCriteria

End Sub

[Stock Reserved Activation] is the form name, [Child0] is the subform name, [ReservedDetail] is the new form I want to open. Is it correct for me to do it like this?

Thanks and Best Wishes,
Gloria

Reply With Quote
  #4  
Old December 12th, 2003, 05:09 AM
TBÁrpi's Avatar
TBÁrpi TBÁrpi is offline
Lazy User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Hungary, Europe
Posts: 337 TBÁrpi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 5 m 5 sec
Reputation Power: 5
Send a message via MSN to TBÁrpi Send a message via Yahoo to TBÁrpi Send a message via Skype to TBÁrpi
Yes, that's correct.
This is the same as the first solution I posted.
The difference is that it puts the WhereCondition into a string variable first.
It seems like a wizard-created code.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Get the current subform value inside a form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT