Group:  Microsoft Access » microsoft.public.access.formscoding
Thread: Code doesn't open my form?

Geek News

Code doesn't open my form?
Tony Williams 12/21/2008 10:11:00 AM
I have a search form that is in continuos forms format. I select a record and
click on a command button to open another form showing the data that I've
picked.At least that's what should happen. However when I click on the button
I get a message that says " You cancelled the previous transaction" Can
anyone help me with this code?

Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim strsemitarefnbr As String
'set strSEMITAREFNbr equal to the selected value before closing the
form, otherwise it will give us an error
strsemitarefnbr = Me.SEMITAREFNbr.Value

Forms!frmMain!SubForm1.SourceObject = "semitavehicle"
Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [semita] WHERE
[SEMITAREFNbr] = '" & strsemitarefnbr & "'"

Exit_cmdopenrecord_Click:
Exit Sub

Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click

End Sub


Thank you
Tony
RE: Code doesn't open my form?
Tony Williams 12/21/2008 11:50:08 AM
I searched Google on the message and I think I narrowed it down to the fact
that SEMITAREFNBR was a number field and the code was for a text field so I
changed the code to another field which is a text field but now I get the
form opening with a blank record. here is my code:
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim strVRM As String
'set strVRM equal to the selected value before closing the form,
otherwise it will give us an error
strVRM = Me.VRM.Value
Forms!frmMain!SubForm1.SourceObject = "semitavehicle"
Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [semita] WHERE
[VRM] = '" & strVRM & "'"

Exit_cmdopenrecord_Click:
Exit Sub

Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click

End Sub

Any help would be appreciated.
Thanks
Tony

"Tony Williams" wrote:

[Quoted Text]
> I have a search form that is in continuos forms format. I select a record and
> click on a command button to open another form showing the data that I've
> picked.At least that's what should happen. However when I click on the button
> I get a message that says " You cancelled the previous transaction" Can
> anyone help me with this code?
>
> Private Sub cmdopenrecord_Click()
> On Error GoTo Err_cmdopenrecord_Click
> Dim strsemitarefnbr As String
> 'set strSEMITAREFNbr equal to the selected value before closing the
> form, otherwise it will give us an error
> strsemitarefnbr = Me.SEMITAREFNbr.Value
>
> Forms!frmMain!SubForm1.SourceObject = "semitavehicle"
> Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [semita] WHERE
> [SEMITAREFNbr] = '" & strsemitarefnbr & "'"
>
> Exit_cmdopenrecord_Click:
> Exit Sub
>
> Err_cmdopenrecord_Click:
> MsgBox Err.Description
> Resume Exit_cmdopenrecord_Click
>
> End Sub
>
>
> Thank you
> Tony
RE: Code doesn't open my form?
Tony Williams 12/21/2008 4:06:01 PM
Please ignore my previous posts as I’ve solved the problem. Well I haven’t
solved what the problem was, I just rebuilt the database from scratch and got
it to work. Funny how these things can be. And frustrating!!!!
Have a great time during the festive season!
Tony


"Tony Williams" wrote:

[Quoted Text]
> I have a search form that is in continuos forms format. I select a record and
> click on a command button to open another form showing the data that I've
> picked.At least that's what should happen. However when I click on the button
> I get a message that says " You cancelled the previous transaction" Can
> anyone help me with this code?
>
> Private Sub cmdopenrecord_Click()
> On Error GoTo Err_cmdopenrecord_Click
> Dim strsemitarefnbr As String
> 'set strSEMITAREFNbr equal to the selected value before closing the
> form, otherwise it will give us an error
> strsemitarefnbr = Me.SEMITAREFNbr.Value
>
> Forms!frmMain!SubForm1.SourceObject = "semitavehicle"
> Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [semita] WHERE
> [SEMITAREFNbr] = '" & strsemitarefnbr & "'"
>
> Exit_cmdopenrecord_Click:
> Exit Sub
>
> Err_cmdopenrecord_Click:
> MsgBox Err.Description
> Resume Exit_cmdopenrecord_Click
>
> End Sub
>
>
> Thank you
> Tony

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net