I am trying to build an Access 2002/2003 database application that I
would like to offer to other writers so they can track submissions.
Just trying to make a helpful tool for writers, poets, or anyone who
submits anything to anywhere, actually... I'm having trouble with the
Visual Basic code for the on click event of a button.
So, I have a form, FormA, whose source is a query. On FormA, there is
a numeric field called FieldA. FieldA corresponds to the primary key
(numeric) of the source table for FormB. On FormB, that same related
field is called FieldB.
I have a button on FormA called ButtonA. When clicked, ButtonA should
open FormB to the record in FormB where FieldB is the same as the
value of FieldA on the record where ButtonA was clicked.
The code that is not working is:
_________________________________________________
Private Sub ButtonA_Click()
CoCmd.OpenForm "FormB",,, FormB.FieldB = FormA.FieldA
End Sub
__________________________________________________
With this, I get Run-time error '424'. Object Required.
I read that "the WhereCondition is just an sql where statement without
the WHERE", but apparently, there is some other syntax or structure I
am missing. Any help greatly appreciated. Thanks! 4 1736
Try ....
CoCmd.OpenForm "FormB",,, "Forms!FormB.FieldB = " & Me.FieldA
Steve
"rik" <ef*********@gmail.comwrote in message
news:1b**********************************@q35g2000 hsg.googlegroups.com...
>I am trying to build an Access 2002/2003 database application that I
would like to offer to other writers so they can track submissions.
Just trying to make a helpful tool for writers, poets, or anyone who
submits anything to anywhere, actually... I'm having trouble with the
Visual Basic code for the on click event of a button.
So, I have a form, FormA, whose source is a query. On FormA, there is
a numeric field called FieldA. FieldA corresponds to the primary key
(numeric) of the source table for FormB. On FormB, that same related
field is called FieldB.
I have a button on FormA called ButtonA. When clicked, ButtonA should
open FormB to the record in FormB where FieldB is the same as the
value of FieldA on the record where ButtonA was clicked.
The code that is not working is:
_________________________________________________
Private Sub ButtonA_Click()
CoCmd.OpenForm "FormB",,, FormB.FieldB = FormA.FieldA
End Sub
__________________________________________________
With this, I get Run-time error '424'. Object Required.
I read that "the WhereCondition is just an sql where statement without
the WHERE", but apparently, there is some other syntax or structure I
am missing. Any help greatly appreciated. Thanks!
Thanks for the suggestion Steve. But that was only able to open FormB,
not showing the corresponding record. Actually the form opens filtered
to a single empty record...
On Oct 14, 10:28*am, "Steve" <nonse...@nomsense.comwrote:
Try ....
CoCmd.OpenForm "FormB",,, "Forms!FormB.FieldB = " & Me.FieldA
Steve
"rik" <efelthau...@gmail.comwrote in message
news:1b**********************************@q35g2000 hsg.googlegroups.com...
rik wrote:
>I am trying to build an Access 2002/2003 database application that I would like to offer to other writers so they can track submissions. Just trying to make a helpful tool for writers, poets, or anyone who submits anything to anywhere, actually... I'm having trouble with the Visual Basic code for the on click event of a button.
So, I have a form, FormA, whose source is a query. On FormA, there is a numeric field called FieldA. FieldA corresponds to the primary key (numeric) of the source table for FormB. On FormB, that same related field is called FieldB.
I have a button on FormA called ButtonA. When clicked, ButtonA should open FormB to the record in FormB where FieldB is the same as the value of FieldA on the record where ButtonA was clicked.
The code that is not working is: _______________________________________________ __ Private Sub ButtonA_Click() CoCmd.OpenForm "FormB",,, FormB.FieldB = FormA.FieldA End Sub _________________________________________________ _
With this, I get Run-time error '424'. Object Required.
I read that "the WhereCondition is just an sql where statement without the WHERE", but apparently, there is some other syntax or structure I am missing. Any help greatly appreciated. Thanks!
The WhereCondition argument is a string, not an expression.
The string usually contains an expression, but you need to
enclose it in quotes and/or concatenate values that results
in a string. Your FormB.FieldB has invalid syntax and is
not in quotes. In addition, you need to refer to **fields**
in FormB's record source table/query, not to controls on the
form.
Assuming that FieldA is a numeric type field, use:
DoCmd.OpenForm "FormB",,, "FieldB = " & Me.FieldA
If FieldA is a Text field, then use:
DoCmd.OpenForm "FormB",,, "FieldB = """ & Me.FieldA & """"
If FieldA is a Date field, then use:
DoCmd.OpenForm "FormB",,, "FieldB = " _
& Format(Me.FieldA, "\#yyyy-m-d\#")
--
Marsh
On Tue, 14 Oct 2008 08:20:56 -0700 (PDT), rik wrote:
I am trying to build an Access 2002/2003 database application that I
would like to offer to other writers so they can track submissions.
Just trying to make a helpful tool for writers, poets, or anyone who
submits anything to anywhere, actually... I'm having trouble with the
Visual Basic code for the on click event of a button.
So, I have a form, FormA, whose source is a query. On FormA, there is
a numeric field called FieldA. FieldA corresponds to the primary key
(numeric) of the source table for FormB. On FormB, that same related
field is called FieldB.
I have a button on FormA called ButtonA. When clicked, ButtonA should
open FormB to the record in FormB where FieldB is the same as the
value of FieldA on the record where ButtonA was clicked.
The code that is not working is:
_________________________________________________
Private Sub ButtonA_Click()
CoCmd.OpenForm "FormB",,, FormB.FieldB = FormA.FieldA
End Sub
__________________________________________________
With this, I get Run-time error '424'. Object Required.
I read that "the WhereCondition is just an sql where statement without
the WHERE", but apparently, there is some other syntax or structure I
am missing. Any help greatly appreciated. Thanks!
[FieldA] is the name of the FIELD in the table/query that you wish to
use to filter records.
[ControlB] is the name of the CONTROL on the form that you are using
to compare values to.
DoCmd.OpenForm "FormB", , , "[FieldA] = " & Me![ControlB]
In other words, open FormB filtered, so that the table/query [FieldA]
value equals the value displayed on the current Form's [ControlB] .
The above syntax is correct if the datatype of [FieldA] is Number
datatype.
See Access help on
Where Clause + Restrict data to a subset of records
for more information as to the proper syntax for other datatypes.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Megan |
last post by:
Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of
text in a textbox, press the 'Enter' key, and have...
|
by: Nothing |
last post by:
I have a form that the user types in a last name to search for then
clicks a search button.
Based on the information I want to open the form using the SQL Where
statement that will pattern match...
|
by: Lyn |
last post by:
Hi,
I have been experiencing a problem passing a LIKE statement in the WHERE
argument of a DoCmd.Openform statement. I have posted that issue
separately.
However, in an attempt to work around...
|
by: dhowell |
last post by:
I have a form with a continuous subform .
subform has a combo box called .
The following code is opening up the form,
but is not applying the "Where" clause which is based on the combo box...
|
by: kaosyeti |
last post by:
is there a way to create simple help file that i plan on linking to a command
button on a form using what's already in access? i will probably be giving
out this db that i've written to a number...
|
by: Mike Charney |
last post by:
I am trying to write an Open Form command in VBA with a where clause in it.
I need to be able to do two different where clauses:
1) With a between in it: i.e. Between Date1 and Date2 or...
|
by: SDL |
last post by:
Help!
I have a system that was running fine and I was testing a bottom level
form. I went from a menu to a screen where I could enter a phone number
or name to find a customer. If the customer...
|
by: Tom_F |
last post by:
To comp.databases.ms-access --
I just discovered, to my more than mild dismay, that some tables in my
Microsoft Access 2003 database have duplicate numbers in the
"AutoNumber" field. (Field...
|
by: gavm360 |
last post by:
Hello, im trying to open a form from an dialog box form:
the button on the dialog box has this on the onclick event:
DoCmd.OpenForm "frmCASES_UNION", acViewNormal, , "MCH_CASECODE = #" &...
|
by: rik |
last post by:
I am trying to build an Access 2002/2003 database application that I
would like to offer to other writers so they can track submissions.
Just trying to make a helpful tool for writers, poets, or...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |