Radio button to open recordset

  • Thread starter Thread starter Joker via AccessMonster.com
  • Start date Start date
J

Joker via AccessMonster.com

Hello all,

I have a form with a subform which is read only. On the subform I have a
list of all my records with radio buttons next to them. I would like the
user to be able to select the radio button next to a record and select a
button to view the full record in a new form so they can edit it. How can
this be achieved? I think this is some how going to have to involve
recordsets, which I'm not very proficient at. Thanks for any thoughts you
can give on this.
 
This doesn't involve recordsets. It is just a matter of opening a form with
a Where Argument. Rather than a radio button, you can use the Double Click
event of a control on the subform. I usually use the primary field, the one
the user would be looking for. Here is an example from one of my apps:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContract"
stLinkCriteria = "[ContractID]=" & Me![ContractID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Thank you very much for the response! It's GREATLY appreciated. I set up
the code as you said and it's now throwing me a 2501 OpenForm action was
cancelled error. I've read about what this error is and it's causes but I'm
not sure why I'm getting it. stDocName equals the correct form.
stLinkCriteria is as follows:
stLinkCriteria = "[LoanNum]=1111111111" which is the loan I want to open.
This is from hovering the mouse over the code in debug mode. Thank you again
for your assistance.
 
Text (10 chr long) but it contains only number values. I need to keep this
as a text field though.
 
Ok, the line in your code:
stLinkCriteria = "[LoanNum]=1111111111"
would be correct for a numeric field. Since LoanNum is a text field, it
should be:
stLinkCriteria = "[LoanNum] = '1111111111'"
 
this is the line in my code:
stLinkCriteria = "[LoanNum]=" & Me![LoanNum]

the result in debug mode is what you're referring to. I tried adding a ' in
a few places in there and it's throwing different errors depending on where I
place it but none of which seems to run. How can I apply that to the line
above?

Ok, the line in your code:
stLinkCriteria = "[LoanNum]=1111111111"
would be correct for a numeric field. Since LoanNum is a text field, it
should be:
stLinkCriteria = "[LoanNum] = '1111111111'"
Text (10 chr long) but it contains only number values. I need to keep this
as a text field though.
 
stLinkCriteria = "[LoanNum]='" & Me![LoanNum] & "'"
Puts the delimiters around it.
--
Dave Hargis, Microsoft Access MVP


Joker via AccessMonster.com said:
this is the line in my code:
stLinkCriteria = "[LoanNum]=" & Me![LoanNum]

the result in debug mode is what you're referring to. I tried adding a ' in
a few places in there and it's throwing different errors depending on where I
place it but none of which seems to run. How can I apply that to the line
above?

Ok, the line in your code:
stLinkCriteria = "[LoanNum]=1111111111"
would be correct for a numeric field. Since LoanNum is a text field, it
should be:
stLinkCriteria = "[LoanNum] = '1111111111'"
Text (10 chr long) but it contains only number values. I need to keep this
as a text field though.
 
PERFECT!!! Thank you so much!!



stLinkCriteria = "[LoanNum]='" & Me![LoanNum] & "'"
Puts the delimiters around it.
this is the line in my code:
stLinkCriteria = "[LoanNum]=" & Me![LoanNum]
[quoted text clipped - 11 lines]
 
Back
Top