freespiritcherishes
Technical User
Hi everyone and anyone!
I have a several forms each with a button called 'more' that opens the same form called 'moredetails'.
My various forms are called:
TodayView
Future
DiaryList
FUBIFF
These forms reside on a Tab Form called Diary. As I said before, each form has a button called 'more'. This button opens up a 'moredetailsform' giving more details of the record. Using the TodayView form in this example of the underlying code:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "moredetails"
stLinkCriteria = "[DiaryID]=" & Me![DiaryID]
DoCmd.OpenForm stDocName, , , stLinkCriteria.
it naturally worked as it was created by the wizard.
However, I don't want to do the same thing with the other forms cos i am just repeating the code. So i created a function.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "moredetails"
stLinkCriteria = "[DiaryID]=" & Forms!Diary![DiaryID]
DoCmd.OpenForm stDocName, , , stLinkCriteria.
with Diary being the Main Form, and called it to the onClick event of each button on each subform (the ones above). The code runs with no errors but instead of bringing up the corresponding DiaryID of the form its in, it just brings up the last DiaryID entered in the recordset. eg, i could click the more button on record 1712 and it will bring up the more details form for the last record entered being 2856.
What sort of statement would i need to tell access that this procedure has to think about being called various forms in order to bring up the corresponding more details form! So thats one piece of code but to identify a different form when its called at runtime depending on what form I click the button.
Am I talking spaghetti?
freespirit
I have a several forms each with a button called 'more' that opens the same form called 'moredetails'.
My various forms are called:
TodayView
Future
DiaryList
FUBIFF
These forms reside on a Tab Form called Diary. As I said before, each form has a button called 'more'. This button opens up a 'moredetailsform' giving more details of the record. Using the TodayView form in this example of the underlying code:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "moredetails"
stLinkCriteria = "[DiaryID]=" & Me![DiaryID]
DoCmd.OpenForm stDocName, , , stLinkCriteria.
it naturally worked as it was created by the wizard.
However, I don't want to do the same thing with the other forms cos i am just repeating the code. So i created a function.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "moredetails"
stLinkCriteria = "[DiaryID]=" & Forms!Diary![DiaryID]
DoCmd.OpenForm stDocName, , , stLinkCriteria.
with Diary being the Main Form, and called it to the onClick event of each button on each subform (the ones above). The code runs with no errors but instead of bringing up the corresponding DiaryID of the form its in, it just brings up the last DiaryID entered in the recordset. eg, i could click the more button on record 1712 and it will bring up the more details form for the last record entered being 2856.
What sort of statement would i need to tell access that this procedure has to think about being called various forms in order to bring up the corresponding more details form! So thats one piece of code but to identify a different form when its called at runtime depending on what form I click the button.
Am I talking spaghetti?
freespirit