Type Mismatch

G

Guest

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
 
D

Douglas J Steele

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?
 
G

Guest

Douglas,

LEAKID is an autonumber field. It in a table. Everytime a leak is entered,
a LEAKID is created, its the primary key.

Thanks

Douglas J Steele said:
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!)


Trini Gal said:
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
 
D

Douglas J Steele

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!)


Trini Gal said:
Douglas,

LEAKID is an autonumber field. It in a table. Everytime a leak is entered,
a LEAKID is created, its the primary key.

Thanks

Douglas J Steele said:
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!)


Trini Gal said:
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
 
G

Guest

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!)


Trini Gal said:
Douglas,

LEAKID is an autonumber field. It in a table. Everytime a leak is entered,
a LEAKID is created, its the primary key.

Thanks

Douglas J Steele said:
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
 
D

Douglas J. Steele

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trini Gal said:
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!)


Trini Gal said:
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
 
V

Van T. Dinh

I think the problem is in this expression:

Forms(FrmName)

In this context FrmName is used as an index (of the Forms Collection).
Usually the index is a String or an Integer value. However, in your case,
you declared FrmName as a (subclassed) Form object rather than String or
Integer.

Thus, my guess (not tested) is the error comes from the above expression.

When you have an error, you should find out which line of code errored out
and post this also. It is much easier for potential respondents to find the
problem this way.

Also, you used With ... End With but then you didn't use the dot operator to
indicate the full reference of the Properties you used. You should have the
dot before RecordsetClone and Bookmark in the correct use of With ... End
With.

I have not checked the rest of your code ...
 
G

Guest

Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine but
I had a problem. Since the form is already opened, the DoCmd.OpenForm is
opening another instance of the form there lies the problem. The main form
within the subform is already opened. The pop up dialog asking for user name
and date, is opened when the user clicks the Edit button. Thats how the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to
write the code for that.

Can you possibly help me with that?

Thanks

Douglas J. Steele said:
How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trini Gal said:
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
 
D

Douglas J Steele

If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine but
I had a problem. Since the form is already opened, the DoCmd.OpenForm is
opening another instance of the form there lies the problem. The main form
within the subform is already opened. The pop up dialog asking for user name
and date, is opened when the user clicks the Edit button. Thats how the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to
write the code for that.

Can you possibly help me with that?

Thanks

Douglas J. Steele said:
How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trini Gal said:
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.



:

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
 
G

Guest

Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form name
or the subform name of the other form? Do I put them in quotes?

Thanks

Douglas J Steele said:
If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine but
I had a problem. Since the form is already opened, the DoCmd.OpenForm is
opening another instance of the form there lies the problem. The main form
within the subform is already opened. The pop up dialog asking for user name
and date, is opened when the user clicks the Edit button. Thats how the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to
write the code for that.

Can you possibly help me with that?

Thanks

Douglas J. Steele said:
How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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
 
D

Douglas J. Steele

The main form name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trini Gal said:
Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form
name
or the subform name of the other form? Do I put them in quotes?

Thanks

Douglas J Steele said:
If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine but
I had a problem. Since the form is already opened, the DoCmd.OpenForm
is
opening another instance of the form there lies the problem. The main form
within the subform is already opened. The pop up dialog asking for
user name
and date, is opened when the user clicks the Edit button. Thats how
the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know
how to
write the code for that.

Can you possibly help me with that?

Thanks

:

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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!)


message
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
 
G

Guest

Douglas,

Its not working. I get a parameter asking for the primary key "LEAKID". I
really don't know what to do now...please help me.

Douglas J. Steele said:
The main form name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trini Gal said:
Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form
name
or the subform name of the other form? Do I put them in quotes?

Thanks

Douglas J Steele said:
If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine
but
I had a problem. Since the form is already opened, the DoCmd.OpenForm
is
opening another instance of the form there lies the problem. The main
form
within the subform is already opened. The pop up dialog asking for
user
name
and date, is opened when the user clicks the Edit button. Thats how
the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know
how
to
write the code for that.

Can you possibly help me with that?

Thanks

:

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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!)


message
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
 
D

Douglas J Steele

Did you rename the text box on the form as I recommended?

And does LEAKID exist in the recordset that is bound to your form?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

Its not working. I get a parameter asking for the primary key "LEAKID". I
really don't know what to do now...please help me.

Douglas J. Steele said:
The main form name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trini Gal said:
Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form
name
or the subform name of the other form? Do I put them in quotes?

Thanks

:

If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine
but
I had a problem. Since the form is already opened, the DoCmd.OpenForm
is
opening another instance of the form there lies the problem. The main
form
within the subform is already opened. The pop up dialog asking for
user
name
and date, is opened when the user clicks the Edit button. Thats how
the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know
how
to
write the code for that.

Can you possibly help me with that?

Thanks

:

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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!)


message
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
 
G

Guest

Douglas,

If you are asking if I changed the name, yes I did. It is as follows:

Name - LEAK
Control Source - LEAKID

Did I need to change the control source? There is a LEAKID in the subform
of the original form and a LEAKID in the Edit form.

Douglas J Steele said:
Did you rename the text box on the form as I recommended?

And does LEAKID exist in the recordset that is bound to your form?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

Its not working. I get a parameter asking for the primary key "LEAKID". I
really don't know what to do now...please help me.

Douglas J. Steele said:
The main form name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form
name
or the subform name of the other form? Do I put them in quotes?

Thanks

:

If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine
but
I had a problem. Since the form is already opened, the DoCmd.OpenForm
is
opening another instance of the form there lies the problem. The main
form
within the subform is already opened. The pop up dialog asking for
user
name
and date, is opened when the user clicks the Edit button. Thats how
the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know
how
to
write the code for that.

Can you possibly help me with that?

Thanks

:

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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!)


message
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
 
G

Guest

I changed them both now. Both the Name and the Control Source are named
"LEAK". My code is as follows:

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
With Forms("frmADD_LEAK_FORM")
.Filter = "LEAKID=" & Me.LEAK
.FilterOn = True
End With
DoCmd.Close acForm, Me.Name

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click

End Sub

I'm still getting the parameter asking for the LEAKID. I don't know if this
helps, but, the LEAKID is not in the main form, its in the subform.

I really appreciate your help.




Douglas J Steele said:
Did you rename the text box on the form as I recommended?

And does LEAKID exist in the recordset that is bound to your form?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

Its not working. I get a parameter asking for the primary key "LEAKID". I
really don't know what to do now...please help me.

Douglas J. Steele said:
The main form name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form
name
or the subform name of the other form? Do I put them in quotes?

Thanks

:

If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that worked fine
but
I had a problem. Since the form is already opened, the DoCmd.OpenForm
is
opening another instance of the form there lies the problem. The main
form
within the subform is already opened. The pop up dialog asking for
user
name
and date, is opened when the user clicks the Edit button. Thats how
the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I don't know
how
to
write the code for that.

Can you possibly help me with that?

Thanks

:

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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!)


message
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
 
D

Douglas J Steele

What's the connection between the main form and the subform?

I was assuming that LEAKID was a key field on the main form.

Before going any further, if the name of the field in the recordset it
LEAKID, the field needs to be bound to that field. All I was trying to do is
not have the control and field have the same name: that can lead to
confusion.

I think you're going to have to step back and explain in a bit of detail.

What tables are involved? What's being shown on your form, what's been shown
on your subform and what's the link between the form and subform?

This thread is getting pretty long: it might be better to start a new one.
That also has the advantage that others who have been ignoring this thread
(thinking it's been resolved) may contribute.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
I changed them both now. Both the Name and the Control Source are named
"LEAK". My code is as follows:

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
With Forms("frmADD_LEAK_FORM")
.Filter = "LEAKID=" & Me.LEAK
.FilterOn = True
End With
DoCmd.Close acForm, Me.Name

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click

End Sub

I'm still getting the parameter asking for the LEAKID. I don't know if this
helps, but, the LEAKID is not in the main form, its in the subform.

I really appreciate your help.




Douglas J Steele said:
Did you rename the text box on the form as I recommended?

And does LEAKID exist in the recordset that is bound to your form?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Trini Gal said:
Douglas,

Its not working. I get a parameter asking for the primary key
"LEAKID".
I
really don't know what to do now...please help me.

:

The main form name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Douglas,

I don't mean to sound stupid but do I replace MyForm with the main form
name
or the subform name of the other form? Do I put them in quotes?

Thanks

:

If the form is already open, you can set a filter for it:

With Forms("MyForm")
.Filter = "LEAKID = " & Me.LEAKID
.FilterOn = True
End With

Note that this code will raise an error if the form is not open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas,

I used the DoCmd.OpenForm, like you had suggested, and that
worked
fine
but
I had a problem. Since the form is already opened, the DoCmd.OpenForm
is
opening another instance of the form there lies the problem.
The
main
form
within the subform is already opened. The pop up dialog asking for
user
name
and date, is opened when the user clicks the Edit button.
Thats
how
the
dialog form is opened.

I was thinking maybe a DoCmd.GoTo Record would work, but I
don't
know
how
to
write the code for that.

Can you possibly help me with that?

Thanks

:

How are you opening the form?

Assuming you're using DoCmd.OpenForm, you can pass it a Where clause:

DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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.



:

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!)


message
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
 

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

Similar Threads


Top