Douglas,
Maybe I am going about this the wrong way. I will tell you what I want to
do, and maybe you can point me in the right direction?
I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM.
In
the subform, I have a command button EDIT, which allows the users to
update/edit exisiting data. I want when the user clicks the EDIT button,
a
pop-up dialog form pops up, asking the user to enter their name and
current
date. When they click the okay button on the pop up form, I want them
taken
to the record they want to update in the subform.
The code I had before was not doing this, the user kept getting taken to
the
first record of the subform. Below is the code I had before. I am new to
VB. I have been trying a lot of different things. Any help will very
much
be appreciated.
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!frmADD_LEAK_FORM.AllowEdits = True
DoCmd.Close acForm, Me.Name
Exit_cmdOK_Click:
Exit Sub
Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click
End Sub
Thanks in advance.
Douglas J Steele said:
If LEAKID is both a field in the underlying recordset AND a textbox on
your
form, you could be running into problems with Access not knowing to which
LEAKID you're trying to refer. What I always do is rename my textbox
controls, so that I'd have txtLEAKID bound to the LEAKID field in the
recordset.
However, if LEAKID is your Autonumber field, why are you trying to set it
to
Null?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Douglas,
LEAKID is an autonumber field. It in a table. Everytime a leak is
entered,
a LEAKID is created, its the primary key.
Thanks
:
What data type is the LEAKID field? If it's text, you need to enclose
the
value being passed in quotes:
RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34)
Also, what is LEAKID: in other words, where are you getting that
value
from?
If it's the name of a control on your form, you might want to use
Me.LEAKID.
If it's a variable that's defined elsewhere, how is it declared?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hello,
Does anyone know why I'm getting a type mismatch error in the
following
code?
rivate Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim FrmName As Form_frmLEAK_FILE_FORM
With Forms(FrmName)
RecordsetClone.FindFirst "LEAKID=" & LEAKID
Bookmark = RecordsetClone.Bookmark
LEAKID = Null
'.setfocus
End With
Exit_cmdOK_Click:
Exit Sub
Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click
End Sub
I want to find a record with [LEAKID] in the subform in the
frmADD_LEAK_FORM
from the frmEDIT_FORM.
Thanks