Code doesn't open my form?

T

Tony Williams

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
 
T

Tony Williams

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
 
T

Tony Williams

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top