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! 7 3866
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!
You need quotes. The WhereCondition is a string.
Ultimately you need it to read something like this:
FieldB = 999
so code like this:
Private Sub ButtonA_Click()
Dim strWhere as String
If Me.Dirty Then Me.Dirty = False
If IsNull(Me.FieldA) Then
MsgBox "There's no FieldA value."
Else
strWhere = "FieldB = " & Me.FieldA
DoCmd.OpenForm "FormB", WhereCondition:=strWhere
End If
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"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
Allen, your code worked Perfectly! Thank you so much. You are really
awesome. I'll try to learn VB myself one of these days.
On Oct 14, 10:31*am, "Allen Browne" <AllenBro...@SeeSig.Invalid>
wrote:
You need quotes. The WhereCondition is a string.
Ultimately you need it to read something like this:
* * FieldB = 999
so code like this:
* * Private Sub ButtonA_Click()
* * * * Dim strWhere as String
* * * * If Me.Dirty Then Me.Dirty = False
* * * * If IsNull(Me.FieldA) Then
* * * * * * MsgBox "There's no FieldA value."
* * * * Else
* * * * * * strWhere = "FieldB = " & Me.FieldA
* * * * * * DoCmd.OpenForm "FormB", WhereCondition:=strWhere
* * * * End If
* * End Sub
--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
Wow. So many responses before I can even reply with success. I'll read
though the others and try to learn from them too. Thanks to everyone
again. I'll try to remember to post a link to the database here once
it's whipped into shape. 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: 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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
| |