get values of selected record in subform

bbouwer

Registered User.
Local time
Today, 21:17
Joined
Dec 23, 2009
Messages
17
Hi,

I have a problem,i want to get the data behind a selected record on a subform.Right now i only get the data of the first record,not of the one selected,can anyone help me ?
 
What method are you using to access the data in the SubForm? Only the Selected record data is available on a continuous form without special coding.
 
I have setup this code:

Public Sub Command4_Click()
' Calculate subfolders,display path and filename and extension
Dim intSubmap1 As Integer
Dim intSubmap2 As Integer
Dim intExt As Integer
Dim A As Long
intExt = 1
intSubmap1 = Int(DWDOCID / (CLng(256) * 256))
intSubmap2 = Int(DWDOCID / 256) And 255 And 255
map1 = Format(intSubmap1, "000")
map2 = Format(intSubmap2, "000")
Do While intExt > DWPAGECOUNT
intExt = intExt + 1
' A = Shell("C:\Program Files\Common Files\microsoft shared\MODI\11.0\MSPVIEW.EXE D:/" & "GIRONR" & "." & Format(DWDISKNO, "000") & "/" & map1 & "/" & map2 & "/" & Format(DWDOCID, "00000000") & "." & Format(intExt, "000"))
MsgBox "Uw dossier bestaat uit " & DWPAGECOUNT & " blz " & "D:/" & map1 & "/" & map2 & "/" & Format(DWDOCID, "00000000") & "." & Format(intExt, "000")
Loop


With this code i only get the data (the msgbox is only to control it) of the first record.

Thanks,
 
I thought this was all in Access using a SubForm? You've got me lost.
 
Sorry,this code is on the form behind a button to open documents connecting to the selected record,

Thanks,
 
Used fields in the record are DWDOCID and DWPAGECOUNT,with these fields a calculation is made to get the 2 folders they are in,and amount of pages connecting to this record.
 
Hi,

Can you help me out please,with my recordsource ?

Me!GIRONR_subform.Form.RecordSource = "SELECT * FROM GIRONR"

I get a failure message,what am i doing wrong ?

Thanks,
 
To get this straight,i want to have use the data of the selected record in a subform
 
You can use the currentrecord property for this, check access help out for sntax etc.
 
Hi,

Can you help me out please,with my recordsource ?

Me!GIRONR_subform.Form.RecordSource = "SELECT * FROM GIRONR"

I get a failure message,what am i doing wrong ?

Thanks,
Now you are trying to change the RecordSource of a SubForm? That is not what you stated in your first post. Have we changed problems?
 
Can anyone help please ?

I am building a query tool to search for stored docs.

In the tables are fields such as DWDOCID(primary key) DWPAGECOUNT(amount of pages) and account numbers.

With these fields a calculation is done to calculate the 2 subfolders where this doc is stored.

I have created a combobox and a subform,a user searches for an account number,and on the subform the result is displayed.After selecting a record and clicking a button the doc is displayed.

I am getting there,but,right now,always the first record is displayed,in stead of the selected record,can anyone help me please ? This is the code behind the button:

Option Compare Database

Private Sub Combo2_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[DWDOCID] = " & Str(Nz(Me![Combo2], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Public Sub Command4_Click()
' Calculate subfolders,display path and filename and extension
Dim intSubmap1 As Integer
Dim intSubmap2 As Integer
Dim intExt As Integer
Dim A As Long
Dim myVar As Byte
intExt = 1
DWCOUNTER = DWDOCID
intSubmap1 = Int(DWCOUNTER / (CLng(256) * 256))
intSubmap2 = Int(DWCOUNTER / 256) And 255 And 255
map1 = Format(intSubmap1, "000")
map2 = Format(intSubmap2, "000")
Do While intExt <= DWPAGECOUNT
A = Shell("C:\Program Files\Common Files\microsoft shared\MODI\11.0\MSPVIEW.EXE D:/" & "GIRONR" & "." & Format(DWDISKNO, "000") & "/" & map1 & "/" & map2 & "/" & Format(DWCOUNTER, "00000000") & "." & Format(intExt, "000"))
' MsgBox "Uw dossier bestaat uit " & DWPAGECOUNT & " blz " & "D:/" & map1 & "/" & map2 & "/" & Format(DWCOUNTER, "00000000") & "." & Format(intExt, "000")
intExt = intExt + 1
DWCOUNTER = DWCOUNTER + 1
myVar = MsgBox("Wilt u de volgende pagina bekijken?", vbYesNo + vbQuestion)
If myVar = 7 Then Exit Sub
Loop
End Sub


Thanks a lot !!
 
OK, so if I understand correctly you filter the subform based upon a value in a combo box on the main form. Then, the user selects a record in the subform, clicks a button and the doc opens.

If it was me I would either have a very simple bit of code in a button in the subform itself, so that every line in the subform has a button to click, or a button in the main form that selects the right record using the gotorecord and currentrecord functions. That will ensure that the code is looking at the selected record in the subform, then when you refer to DWPAGECOUNT and DWCOUNTER, it should bring back the right values. You'll have to consult the help file as to exact syntax.

But I'd go with the one-button-per record method, much simpler!
 

Users who are viewing this thread

Back
Top Bottom