C
Courtney G
Can anyone assist with the following question? I would really appreciate
your help! . . .
your help! . . .
KenSheridan via AccessMonster.com said:I can't see any obvious error in your code. Often this error arises if the
parameter reference is hard coded into the string expression such as :
strSql = "select * from tbl_Enquiries where id = Forms!MyForm!EnquiryID
but you have correctly concatenated the value of EnquiryID with:
strSql = "select * from tbl_Enquiries where id = " & Me!EnquiryID
so it should be fine, but is the primary key of tbl_Enquiries really named id
rather than EnquiryID? If not that could be the problem.
However, I think this might be a 'road to Dublin' question, as it looks to me
as if you may be introducing some redundancy. Are you attempting to assign
the values from the tbl_Enquiries table to columns (fields) in the
tbl_Projects table underlying your current form? If so you don't need to do
so, nor should you as redundancy is not only inefficient, but more
importantly leaves the database at risk of inconsistent data creeping in.
Delete all the address columns from the tbl_Projects table and simply base
you form on a query which joins tbl_Projects to tbl_Enquiries on EnquiryID.
In the query include the address columns from tbl_Enquiries and in the form
include text box controls bound to those columns. The EnquryID control in
the form should be bound to the column from tbl_Projects not that from
tbl_Enquiries BTW.
When an EnquiryID is entered in the form the address values from
tbl_Enquiries will show in the text box controls. If you want to prevent the
values being inadvertently edited set the Locked property of each address
control to True (Yes) and the Enabled property to False (No).
Ken Sheridan
Stafford, England
Courtney said:Can anyone assist with the following question? I would really appreciate
your help! . . .
[quoted text clipped - 50 lines]Courtney G said:Thank you for your advice. This is the first time I have tried to work with
code, so please bear with me.in the above, customer_id is the forighn key collum used to relate back to
the customers table.
Courtney G said:I would like to thank all of you for your assistance; however, I have
still
not been able to get the code to work. It currently reads as follows:
Private Sub Command106_Click()
Dim rstCust As DAO.Recordset
Dim strSql As String
strSql = "select * from tbl_Enquiries where EnquiryID = '" &
Me!EnquiryID
& "'"
Set rstCust = CurrentDb.OpenRecordset(strSql)
Me.ProjectAddressLine1 = rstCust!PostalAddressLine1
Me.ProjectAddressLine2 = rstCust!PostalAddressLine2
Me.ProjectAddressLine3 = rstCust!PostalAddressLine3
Me.ProjectCity_Town = rstCust!PostalCity
Me.ProjectCounty = rstCust!PostalCounty
Me.ProjectPostCode = rstCust!PostalPostcode
rst.Close
End Sub
After I made some changes using your suggestions. I am still getting the
following error:
Run-time error '3464': Data type mismatch in criteria expression
If I click 'Debug' then the following line is highlighted in the MVBA
window:
Set rstCust = CurrentDb.OpenRecordset(strSql)
Thank you in advance if you are able to help.
KenSheridan via AccessMonster.com said:I can't see any obvious error in your code. Often this error arises if
the
parameter reference is hard coded into the string expression such as :
strSql = "select * from tbl_Enquiries where id = Forms!MyForm!EnquiryID
but you have correctly concatenated the value of EnquiryID with:
strSql = "select * from tbl_Enquiries where id = " & Me!EnquiryID
so it should be fine, but is the primary key of tbl_Enquiries really
named id
rather than EnquiryID? If not that could be the problem.
However, I think this might be a 'road to Dublin' question, as it looks
to me
as if you may be introducing some redundancy. Are you attempting to
assign
the values from the tbl_Enquiries table to columns (fields) in the
tbl_Projects table underlying your current form? If so you don't need to
do
so, nor should you as redundancy is not only inefficient, but more
importantly leaves the database at risk of inconsistent data creeping in.
Delete all the address columns from the tbl_Projects table and simply
base
you form on a query which joins tbl_Projects to tbl_Enquiries on
EnquiryID.
In the query include the address columns from tbl_Enquiries and in the
form
include text box controls bound to those columns. The EnquryID control
in
the form should be bound to the column from tbl_Projects not that from
tbl_Enquiries BTW.
When an EnquiryID is entered in the form the address values from
tbl_Enquiries will show in the text box controls. If you want to prevent
the
values being inadvertently edited set the Locked property of each address
control to True (Yes) and the Enabled property to False (No).
Ken Sheridan
Stafford, England
Courtney said:Can anyone assist with the following question? I would really
appreciate
your help! . . .
:
Thank you for your advice. This is the first time I have tried to
work with
code, so please bear with me.
[quoted text clipped - 50 lines]
in the above, customer_id is the forighn key collum used to relate
back to
the customers table.
Douglas J. Steele said:Is EnquiryID a numeric field? If so, you need
strSql = "select * from tbl_Enquiries where EnquiryID = " & Me!EnquiryID
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Courtney G said:I would like to thank all of you for your assistance; however, I have
still
not been able to get the code to work. It currently reads as follows:
Private Sub Command106_Click()
Dim rstCust As DAO.Recordset
Dim strSql As String
strSql = "select * from tbl_Enquiries where EnquiryID = '" &
Me!EnquiryID
& "'"
Set rstCust = CurrentDb.OpenRecordset(strSql)
Me.ProjectAddressLine1 = rstCust!PostalAddressLine1
Me.ProjectAddressLine2 = rstCust!PostalAddressLine2
Me.ProjectAddressLine3 = rstCust!PostalAddressLine3
Me.ProjectCity_Town = rstCust!PostalCity
Me.ProjectCounty = rstCust!PostalCounty
Me.ProjectPostCode = rstCust!PostalPostcode
rst.Close
End Sub
After I made some changes using your suggestions. I am still getting the
following error:
Run-time error '3464': Data type mismatch in criteria expression
If I click 'Debug' then the following line is highlighted in the MVBA
window:
Set rstCust = CurrentDb.OpenRecordset(strSql)
Thank you in advance if you are able to help.
KenSheridan via AccessMonster.com said:I can't see any obvious error in your code. Often this error arises if
the
parameter reference is hard coded into the string expression such as :
strSql = "select * from tbl_Enquiries where id = Forms!MyForm!EnquiryID
but you have correctly concatenated the value of EnquiryID with:
strSql = "select * from tbl_Enquiries where id = " & Me!EnquiryID
so it should be fine, but is the primary key of tbl_Enquiries really
named id
rather than EnquiryID? If not that could be the problem.
However, I think this might be a 'road to Dublin' question, as it looks
to me
as if you may be introducing some redundancy. Are you attempting to
assign
the values from the tbl_Enquiries table to columns (fields) in the
tbl_Projects table underlying your current form? If so you don't need to
do
so, nor should you as redundancy is not only inefficient, but more
importantly leaves the database at risk of inconsistent data creeping in.
Delete all the address columns from the tbl_Projects table and simply
base
you form on a query which joins tbl_Projects to tbl_Enquiries on
EnquiryID.
In the query include the address columns from tbl_Enquiries and in the
form
include text box controls bound to those columns. The EnquryID control
in
the form should be bound to the column from tbl_Projects not that from
tbl_Enquiries BTW.
When an EnquiryID is entered in the form the address values from
tbl_Enquiries will show in the text box controls. If you want to prevent
the
values being inadvertently edited set the Locked property of each address
control to True (Yes) and the Enabled property to False (No).
Ken Sheridan
Stafford, England
Courtney G wrote:
Can anyone assist with the following question? I would really
appreciate
your help! . . .
:
Thank you for your advice. This is the first time I have tried to
work with
code, so please bear with me.
[quoted text clipped - 50 lines]
in the above, customer_id is the forighn key collum used to relate
back to
the customers table.
Courtney G said:Dear Douglas,
Yes - it is a numeric field. I have changed it and am now getting the
following error: Runtime error 424: Object required.
When I click debug, the rst.Close line is highlighted.
Thank you for your help! I think we're closer to the answer!!
- Courtney
Douglas J. Steele said:Is EnquiryID a numeric field? If so, you need
strSql = "select * from tbl_Enquiries where EnquiryID = " & Me!EnquiryID
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Courtney G said:I would like to thank all of you for your assistance; however, I have
still
not been able to get the code to work. It currently reads as follows:
Private Sub Command106_Click()
Dim rstCust As DAO.Recordset
Dim strSql As String
strSql = "select * from tbl_Enquiries where EnquiryID = '" &
Me!EnquiryID
& "'"
Set rstCust = CurrentDb.OpenRecordset(strSql)
Me.ProjectAddressLine1 = rstCust!PostalAddressLine1
Me.ProjectAddressLine2 = rstCust!PostalAddressLine2
Me.ProjectAddressLine3 = rstCust!PostalAddressLine3
Me.ProjectCity_Town = rstCust!PostalCity
Me.ProjectCounty = rstCust!PostalCounty
Me.ProjectPostCode = rstCust!PostalPostcode
rst.Close
End Sub
After I made some changes using your suggestions. I am still getting
the
following error:
Run-time error '3464': Data type mismatch in criteria expression
If I click 'Debug' then the following line is highlighted in the MVBA
window:
Set rstCust = CurrentDb.OpenRecordset(strSql)
Thank you in advance if you are able to help.
:
I can't see any obvious error in your code. Often this error arises
if
the
parameter reference is hard coded into the string expression such as :
strSql = "select * from tbl_Enquiries where id =
Forms!MyForm!EnquiryID
but you have correctly concatenated the value of EnquiryID with:
strSql = "select * from tbl_Enquiries where id = " & Me!EnquiryID
so it should be fine, but is the primary key of tbl_Enquiries really
named id
rather than EnquiryID? If not that could be the problem.
However, I think this might be a 'road to Dublin' question, as it
looks
to me
as if you may be introducing some redundancy. Are you attempting to
assign
the values from the tbl_Enquiries table to columns (fields) in the
tbl_Projects table underlying your current form? If so you don't need
to
do
so, nor should you as redundancy is not only inefficient, but more
importantly leaves the database at risk of inconsistent data creeping
in.
Delete all the address columns from the tbl_Projects table and simply
base
you form on a query which joins tbl_Projects to tbl_Enquiries on
EnquiryID.
In the query include the address columns from tbl_Enquiries and in the
form
include text box controls bound to those columns. The EnquryID
control
in
the form should be bound to the column from tbl_Projects not that from
tbl_Enquiries BTW.
When an EnquiryID is entered in the form the address values from
tbl_Enquiries will show in the text box controls. If you want to
prevent
the
values being inadvertently edited set the Locked property of each
address
control to True (Yes) and the Enabled property to False (No).
Ken Sheridan
Stafford, England
Courtney G wrote:
Can anyone assist with the following question? I would really
appreciate
your help! . . .
:
Thank you for your advice. This is the first time I have tried to
work with
code, so please bear with me.
[quoted text clipped - 50 lines]
in the above, customer_id is the forighn key collum used to
relate
back to
the customers table.
Douglas J. Steele said:You're opening rstCust, but you're trying to close rst.
Change it to
rstCust.Close
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Courtney G said:Dear Douglas,
Yes - it is a numeric field. I have changed it and am now getting the
following error: Runtime error 424: Object required.
When I click debug, the rst.Close line is highlighted.
Thank you for your help! I think we're closer to the answer!!
- Courtney
Douglas J. Steele said:Is EnquiryID a numeric field? If so, you need
strSql = "select * from tbl_Enquiries where EnquiryID = " & Me!EnquiryID
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I would like to thank all of you for your assistance; however, I have
still
not been able to get the code to work. It currently reads as follows:
Private Sub Command106_Click()
Dim rstCust As DAO.Recordset
Dim strSql As String
strSql = "select * from tbl_Enquiries where EnquiryID = '" &
Me!EnquiryID
& "'"
Set rstCust = CurrentDb.OpenRecordset(strSql)
Me.ProjectAddressLine1 = rstCust!PostalAddressLine1
Me.ProjectAddressLine2 = rstCust!PostalAddressLine2
Me.ProjectAddressLine3 = rstCust!PostalAddressLine3
Me.ProjectCity_Town = rstCust!PostalCity
Me.ProjectCounty = rstCust!PostalCounty
Me.ProjectPostCode = rstCust!PostalPostcode
rst.Close
End Sub
After I made some changes using your suggestions. I am still getting
the
following error:
Run-time error '3464': Data type mismatch in criteria expression
If I click 'Debug' then the following line is highlighted in the MVBA
window:
Set rstCust = CurrentDb.OpenRecordset(strSql)
Thank you in advance if you are able to help.
:
I can't see any obvious error in your code. Often this error arises
if
the
parameter reference is hard coded into the string expression such as :
strSql = "select * from tbl_Enquiries where id =
Forms!MyForm!EnquiryID
but you have correctly concatenated the value of EnquiryID with:
strSql = "select * from tbl_Enquiries where id = " & Me!EnquiryID
so it should be fine, but is the primary key of tbl_Enquiries really
named id
rather than EnquiryID? If not that could be the problem.
However, I think this might be a 'road to Dublin' question, as it
looks
to me
as if you may be introducing some redundancy. Are you attempting to
assign
the values from the tbl_Enquiries table to columns (fields) in the
tbl_Projects table underlying your current form? If so you don't need
to
do
so, nor should you as redundancy is not only inefficient, but more
importantly leaves the database at risk of inconsistent data creeping
in.
Delete all the address columns from the tbl_Projects table and simply
base
you form on a query which joins tbl_Projects to tbl_Enquiries on
EnquiryID.
In the query include the address columns from tbl_Enquiries and in the
form
include text box controls bound to those columns. The EnquryID
control
in
the form should be bound to the column from tbl_Projects not that from
tbl_Enquiries BTW.
When an EnquiryID is entered in the form the address values from
tbl_Enquiries will show in the text box controls. If you want to
prevent
the
values being inadvertently edited set the Locked property of each
address
control to True (Yes) and the Enabled property to False (No).
Ken Sheridan
Stafford, England
Courtney G wrote:
Can anyone assist with the following question? I would really
appreciate
your help! . . .
:
Thank you for your advice. This is the first time I have tried to
work with
code, so please bear with me.
[quoted text clipped - 50 lines]
in the above, customer_id is the forighn key collum used to
relate
back to
the customers table.