![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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! |
#3
| |||
| |||
|
|
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
| |||
| |||
|
|
Try .... CoCmd.OpenForm "FormB",,, "Forms!FormB.FieldB = " & Me.FieldA Steve "rik" <efelthau... (AT) gmail (DOT) com> wrote in message news:1bf9319c-1a87-4780-b3d8-8bc66d7e0d39 (AT) q35g2000hsg (DOT) googlegroups.com... |
#5
| |||
| |||
|
|
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! |
#6
| |||
| |||
|
|
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. |
#7
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |