Hi,
I have a question regarding placing the Where condition in this section of code - Private Sub Command219_Click()
-
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
-
If IsNull(Me!ContactID) Then
-
MsgBox "Please select a valid record", _
-
vbOKOnly, "Error"
-
Exit Sub
-
End If
-
DoCmd.OpenReport "mailmerge", acViewPreview, , _
-
"ContactID = " & Me!ContactID
-
end sub
I need to insert 2 additional where conditions for the report, one being a checkbox and another testing for a value of 1.
The SQL would be - WHERE (((Letters.PrintF)=-1) AND ((Letters.RecpID)=1));
Can anyone help me convert this into the VB?
Thanks
7 1981
Hi,
I have a question regarding placing the Where condition in this section of code - Private Sub Command219_Click()
-
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
-
If IsNull(Me!ContactID) Then
-
MsgBox "Please select a valid record", _
-
vbOKOnly, "Error"
-
Exit Sub
-
End If
-
DoCmd.OpenReport "mailmerge", acViewPreview, , _
-
"ContactID = " & Me!ContactID
-
end sub
I need to insert 2 additional where conditions for the report, one being a checkbox and another testing for a value of 1.
The SQL would be - WHERE (((Letters.PrintF)=-1) AND ((Letters.RecpID)=1));
Can anyone help me convert this into the VB?
Thanks
I put the ContactID last since it seems to be a value coming from the form and the other values are hard coded.
"PrintF=-1 AND RecpID=1 AND ContactID = " & Me!ContactID
As long as it is a viable WHERE clause you don't need all of the brackets the QBE uses.
Hi Jaxjagfan
Thanks for the quick reply!
I gave it a go and it produced an error. I should have explained that ContactID is the main form and the PrintF and RecpID values are on a linked form.
The original code selects the current record displayed but I get an error when I try to further filter these results by using values form the letters form.
Apologies for not being clearer!
Hi Jaxjagfan
Thanks for the quick reply!
I gave it a go and it produced an error. I should have explained that ContactID is the main form and the PrintF and RecpID values are on a linked form.
The original code selects the current record displayed but I get an error when I try to further filter these results by using values form the letters form.
Apologies for not being clearer!
Try this (assuming the name of the subform control is "Letters"):
"Me!Letters.PrintF=-1 AND Me!Letters.RecpID=1 AND ContactID = " & Me!ContactID
or you may have to use this format to reference the subform values:
Forms.YourMainFormName.SubformContainerName.Form.C ontrolName
What is the name of the main form?
Try this (assuming the name of the subform control is "Letters"):
"Me!Letters.PrintF=-1 AND Me!Letters.RecpID=1 AND ContactID = " & Me!ContactID
or you may have to use this format to reference the subform values:
Forms.YourMainFormName.SubformContainerName.Form.C ontrolName
What is the name of the main form?
My mainform is Contacts and the subform is Letters
I gave the above example and -
"Forms.Contacts.Letters.Form.PrintF=-1 AND Forms.Contacts.Letters.Form.RecpID=1 AND ContactID = " & Me!ContactID
a go but on running it i was asked to enter the parameter value. I can't think of what else I am missing.
My mainform is Contacts and the subform is Letters
I gave the above example and -
"Forms.Contacts.Letters.Form.PrintF=-1 AND Forms.Contacts.Letters.Form.RecpID=1 AND ContactID = " & Me!ContactID
a go but on running it i was asked to enter the parameter value. I can't think of what else I am missing.
Look at the main form in design view. Select the control that contains the subform not the subform itself. Look at the properties of this control and see what its name is. Is it "Letters"?
FYI - You should get into the habit of satndardizing your naming. I'm not always consistent myself (but should be). It would be frmContacts, tblContacts, qryContacts, etc.
Look at the main form in design view. Select the control that contains the subform not the subform itself. Look at the properties of this control and see what its name is. Is it "Letters"?
FYI - You should get into the habit of satndardizing your naming. I'm not always consistent myself (but should be). It would be frmContacts, tblContacts, qryContacts, etc.
Actually now you mention, the mainform is called Contacts but the subform is called Letter Detail Form that is again placed in another form Letters which is then placed on the main form.
So it goes Contacts > Letters > Letter Detail Form.
Letter Detail Form being the one with the information needed.
Got sorted thanks, took me a while but finally got there.
I am going to have to tidy up the names as you said, would be alot easier to follow for me and others.
Thanks for the help!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: stoppal |
last post by:
I need some help.
I am trying to write a query which does the following
SELECT * from table1 where field1=(SELECT distinct field1 FROM table1
WHERE field2='2005' or field2='2010')
|
by: xixi |
last post by:
hi, we are using db2 udb v8.1 on windows, i have a table contains over
one million records, it has seperate own tablespace than others, with
bufferpool size 250, i have created multiple views on...
|
by: John Welch |
last post by:
I have a command button with the following code:
DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1"
(SearchAssignmentID is the PK, auto number)
When it runs, the form opens but...
|
by: Sreedhar Vankayala |
last post by:
Hi,
I have a table IV00108wc which contains several thousand records in whcih
ITEMNMBR is the primary key.
I have a com+ object returning recordset which has ITEMNMBR and another
details...
|
by: Peter Alberer |
last post by:
Hi there,
i have a problem with a query that uses the result of a plsql function
In the where clause:
SELECT
assignments.assignment_id,
assignments.package_id AS package_id,...
|
by: Emin |
last post by:
Dear Experts,
I have a fairly simple query in which adding a where clause slows
things down by at least a factor of 100. The following is the slow
version of the query
...
|
by: Ely |
last post by:
Can some one write me the code in Visual Basic for an expretion
similar to the Where Condition to open a report? I can't use the
Where Condition because it pop up a message of Microsoft database...
|
by: Jane T |
last post by:
I appreciate how difficult it is to resolve a problem without all the
information but maybe someone has come across a similar problem.
I have an 'extract' table which has 1853 rows when I ask for...
|
by: SambhajiB |
last post by:
Hi,
I am using Access 2003 and .Net 2005.
I have one problem in access query. I am trying to send the condtion of where clause through parameter to Access query as follows...
PARAMETERS ...
|
by: MARIEDB2 |
last post by:
Hello,
I am struggling to build a query on a DB2 db wich does an update for multiple fields which are the result of a select query with where clause (using multiple tables in the condition).
...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |