Opening a form by Double clicking records in subform

A

Ayo

I have a form with a subform embedded on it. I created a button that I use to
create a filter on my database. The result of the filter is displayed in the
subform. Now, what I want to be able to do is click on a row in the subform
and I want the complete record of the row I clicked on to be displayed on the
main form. I tried using thess two functions:
Function OpenRecordForEditing()
If Not IsNull([Invoice Number]) Then
DoCmd.OpenForm "Invoice Tracker", OpenArgs:=1, datamode:=acFormEdit, _
wherecondition:="[Invoice Number]= " & [Invoice Number] & ""
End If
End Function

Function OpenRecordForEditing()
DoCmd.FindRecord "Invoice Number", acEntire
End Function

Neither of them worked. Any ideas? Thanks.
 
J

John W. Vinson

I have a form with a subform embedded on it. I created a button that I use to
create a filter on my database. The result of the filter is displayed in the
subform. Now, what I want to be able to do is click on a row in the subform
and I want the complete record of the row I clicked on to be displayed on the
main form. I tried using thess two functions:
Function OpenRecordForEditing()
If Not IsNull([Invoice Number]) Then
DoCmd.OpenForm "Invoice Tracker", OpenArgs:=1, datamode:=acFormEdit, _
wherecondition:="[Invoice Number]= " & [Invoice Number] & ""
End If
End Function

Function OpenRecordForEditing()
DoCmd.FindRecord "Invoice Number", acEntire
End Function

Neither of them worked. Any ideas? Thanks.

What "didn't work"? How are you calling the function - from the Click event of
a button? What's that button's code?

The first function should open the form. If Invoice Number is a Text field the
syntax needs one change - you're concatnating an empty string, which does
nothing whatsoever (it's like adding 0 to a number). Instead use ' delimiters
within the string:

wherecondition:="[Invoice Number]= '" & [Invoice Number] & "'"

For clarity (don't do it this way!)

wherecondition:="[Invoice Number]= ' " & [Invoice Number] & " ' "



John W. Vinson [MVP]
 
A

Ayo

Thanks John. It was the delimeters.

John W. Vinson said:
I have a form with a subform embedded on it. I created a button that I use to
create a filter on my database. The result of the filter is displayed in the
subform. Now, what I want to be able to do is click on a row in the subform
and I want the complete record of the row I clicked on to be displayed on the
main form. I tried using thess two functions:
Function OpenRecordForEditing()
If Not IsNull([Invoice Number]) Then
DoCmd.OpenForm "Invoice Tracker", OpenArgs:=1, datamode:=acFormEdit, _
wherecondition:="[Invoice Number]= " & [Invoice Number] & ""
End If
End Function

Function OpenRecordForEditing()
DoCmd.FindRecord "Invoice Number", acEntire
End Function

Neither of them worked. Any ideas? Thanks.

What "didn't work"? How are you calling the function - from the Click event of
a button? What's that button's code?

The first function should open the form. If Invoice Number is a Text field the
syntax needs one change - you're concatnating an empty string, which does
nothing whatsoever (it's like adding 0 to a number). Instead use ' delimiters
within the string:

wherecondition:="[Invoice Number]= '" & [Invoice Number] & "'"

For clarity (don't do it this way!)

wherecondition:="[Invoice Number]= ' " & [Invoice Number] & " ' "



John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top