Record Selection

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi,

I am trying to write the code to request input from the
user and then open a form to the correct record for
editing.

The table tied to the form is Startup and the field in
that table that is being used for comparison with the
user input is "Study Number" This field is designated as
a number. The field in the form that contains the user
input is txtUpdate1. This unbound text box is designated
as a general number. I have the code below on the
OnClick event of a command button on the form:

DoCmd.OpenForm "frmStudyData", acNormal, , "[Study
Number] = " & Forms!frmUpdate1!txtUpdate1 & ""

While it does open the form without an error, it does not
open to the correct record.

Any help would be greatly appreciated

Thanks
 
The table tied to the form is Startup and the field in
that table that is being used for comparison with the
user input is "Study Number" This field is designated as
a number. The field in the form that contains the user
input is txtUpdate1. This unbound text box is designated
as a general number. I have the code below on the
OnClick event of a command button on the form:

DoCmd.OpenForm "frmStudyData", acNormal, , "[Study
Number] = " & Forms!frmUpdate1!txtUpdate1 & ""

Remove the (& "") from the end of the above line so it reads:

DoCmd.OpenForm "frmStudyData", acNormal, , _
"[Study Number] = " & Forms!frmUpdate1!txtUpdate1

Appending the "" to the end of the value passed to the WhereCondition is
converting your number to a string.
 
Thanks for the reply Bruce. I did as you instructed, but
the form is still opening to a blank record
-----Original Message-----
The table tied to the form is Startup and the field in
that table that is being used for comparison with the
user input is "Study Number" This field is designated as
a number. The field in the form that contains the user
input is txtUpdate1. This unbound text box is designated
as a general number. I have the code below on the
OnClick event of a command button on the form:

DoCmd.OpenForm "frmStudyData", acNormal, , "[Study
Number] = " & Forms!frmUpdate1!txtUpdate1 & ""

Remove the (& "") from the end of the above line so it reads:

DoCmd.OpenForm "frmStudyData", acNormal, , _
"[Study Number] = " & Forms!frmUpdate1! txtUpdate1

Appending the "" to the end of the value passed to the WhereCondition is
converting your number to a string.

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 
Thanks for the reply Bruce. I did as you instructed, but
the form is still opening to a blank record

Is the field "Study Number" defined in the table as a number field or a text
field? If it is a text field, you will need to modify your code to read:

DoCmd.OpenForm "frmStudyData", acNormal, , _
"[Study Number] = """ & Forms!frmUpdate1!txtUpdate1 & """"
 
Back
Top