With earlier help from this group (thanks Ben!) I've ended up with this
OnLoad code for my popup form:
Private Sub Form_Load()
If IsNull([Forms]![frmCustomerOrders]![MarketPlaceID]) = True Then
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]!OrderID = Null"
Else
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]![MarketPlaceID]=[Forms]![frmCustomerOrders]![MarketPlaceID]"
End If
End Sub
So, if MarketPlaceID is null on the parent form, the popup form displays
records where there is no OrderID, otherwise it displays records where the
MarketPlaceID matches.
I need to tweak it because there are some instances where the MarketPlaceID
exists on the parent form but may not match any of the MarketPlaceID in the
tempOrders table. I've looked at unmatched queries but that only seems to
cater for unmatches netween to tables and not a table and a form value. I've
briefly looked at WHERE NOT EXISTS and wonder if that is the way forward? If
so I'm a bit sketchy as to how to insert it into the code above?
Thanks
Alan 7 3482
Hi, Alan,
"Alan" wrote...
With earlier help from this group (thanks Ben!) I've ended up with this
OnLoad code for my popup form:
Private Sub Form_Load()
If IsNull([Forms]![frmCustomerOrders]![MarketPlaceID]) = True Then
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]!OrderID = Null"
Else
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]![MarketPlaceID]=[Forms]![frmCustomerOrders]![MarketPlaceID]"
End If
End Sub
So, if MarketPlaceID is null on the parent form, the popup form displays
records where there is no OrderID, otherwise it displays records where the
MarketPlaceID matches.
I need to tweak it because there are some instances where the
MarketPlaceID
exists on the parent form but may not match any of the MarketPlaceID in
the
tempOrders table. I've looked at unmatched queries but that only seems to
cater for unmatches netween to tables and not a table and a form value.
I've
briefly looked at WHERE NOT EXISTS and wonder if that is the way forward?
If
so I'm a bit sketchy as to how to insert it into the code above?
I think it should look something like this:
---------------Code
Private Sub Form_Load()
If IsNull([Forms]![frmCustomerOrders]![MarketPlaceID]) = True Then
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]!OrderID = Null"
Elseif DCount("OrderID","tempOrders","OrderID = " &
[Forms]![frmCustomerOrders]![MarketPlaceID])=0 Then
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]!OrderID = Null"
Else
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]![MarketPlaceID]=[Forms]![frmCustomerOrders]![MarketPlaceID]"
End If
End Sub
---------------Code
regards
Michael
I think it should look something like this:
---------------Code
Private Sub Form_Load()
If IsNull([Forms]![frmCustomerOrders]![MarketPlaceID]) = True Then
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]!OrderID = Null"
Elseif DCount("OrderID","tempOrders","OrderID = " &
[Forms]![frmCustomerOrders]![MarketPlaceID])=0 Then
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]!OrderID = Null"
Else
Me.RecordSource = "SELECT [tempOrders].* FROM [tempOrders] WHERE
[tempOrders]![MarketPlaceID]=[Forms]![frmCustomerOrders]![MarketPlaceID]"
End If
End Sub
---------------Code
regards
Michael
Thanks for the quick reply Michael,
The code appears to work for blank MarketPlaceID on the form but for
non-existent or existing MarketPlaceIDs, when I load the form I get:
Run-time error 64479
The expression you entered as a query paramater produced this error. 'The
object doesn't contain the automation object ' <<it lists the entry for
MarketPlaceID here>>
When I debug it's highlighting:
Elseif DCount("OrderID","tempOrders","OrderID = " &
[Forms]![frmCustomerOrders]![MarketPlaceID])=0 Then
I'm on Access 97 by the way, in case it's one of those version related
syntax issues!
Thanks again
Alan
Run-time error 64479
The expression you entered as a query paramater produced this error. 'The
object doesn't contain the automation object ' <<it lists the entry for
MarketPlaceID here>>
When I debug it's highlighting:
Elseif DCount("OrderID","tempOrders","OrderID = " &
[Forms]![frmCustomerOrders]![MarketPlaceID])=0 Then
I'm on Access 97 by the way, in case it's one of those version related
syntax issues!
Thanks again
Alan
Actually, could it be to do with the fact that OrderID is a long integer and
MarketPlaceID (which is sometimes alphanumeric) is text?
Thanks
Alan
Hi Alan,
"Alan" wrote...
>
Actually, could it be to do with the fact that OrderID is a long integer
and
MarketPlaceID (which is sometimes alphanumeric) is text?
yup, that should be the error.
If it's alphanumeric, you should put " & chr(34) & " in front of and behind
the [Forms]![frmCustomerOrders]![MarketPlaceID].
Regards
Michael
yup, that should be the error.
If it's alphanumeric, you should put " & chr(34) & " in front of and
behind
the [Forms]![frmCustomerOrders]![MarketPlaceID].
Regards
Michael
Thanks for the response Michael,
Like this?
Elseif DCount("OrderID","tempOrders","OrderID = " & chr(34) &
[Forms]![frmCustomerOrders]![MarketPlaceID] & chr(34))=0
I get a data type mismatch on that one. Have I keyed it in wrong?
Thanks
Alan
Hi Alan,
"Alan" wrote...
>
Like this?
Elseif DCount("OrderID","tempOrders","OrderID = " & chr(34) &
[Forms]![frmCustomerOrders]![MarketPlaceID] & chr(34))=0
I get a data type mismatch on that one. Have I keyed it in wrong?
coding is completely correct. The data type mismatch is happening 'cause you
try to search for a string in an integer data type field. You should change
the OrderID to Text if possible, as is the MarketPlaceID. Otherwise you'd
have to drop the "chr(34)" again and first try to find out if
"MarketPlaceID" is not a string. If it is one, you cannot query your OrderID
with your MarketPlaceID.
Yours,
Michael
Thanks Michael,
"Michael Theymann" <el*@maithai.dewrote in message
news:eh*************@news.t-online.com...
Like this?
Elseif DCount("OrderID","tempOrders","OrderID = " & chr(34) &
[Forms]![frmCustomerOrders]![MarketPlaceID] & chr(34))=0
I get a data type mismatch on that one. Have I keyed it in wrong?
coding is completely correct. The data type mismatch is happening 'cause
you
try to search for a string in an integer data type field. You should
change
the OrderID to Text if possible, as is the MarketPlaceID. Otherwise you'd
have to drop the "chr(34)" again and first try to find out if
"MarketPlaceID" is not a string. If it is one, you cannot query your
OrderID
with your MarketPlaceID.
OK, I see what the problem is and what the code is trying to do. Indeed, the
OrderID is numeric and the marketpaceid is text (as it meant to be linked to
ebay user names). I'll do as you say and change the OrderID to text.
Thanks for all your help on this, this has helped save a lot of time for me
and for the people who will be using this form!
Alan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Almir |
last post by:
I have a simple problem, i just can get a grasp on it. I designed a
database for inventory of computer equipment. Now i created forms for
each table. Each piece of equipment is going to come in an...
|
by: Paul |
last post by:
I have a basic form. On it are two sub forms. The top sub form has a
list of records. When a user clicks on a new row within the top sub
form. I want the RecordSource of the bottom sub form to...
|
by: Bruce Dodds |
last post by:
I'm trying to set a tabledef object from a form object's RecordSource in
Access 97. This is the code:
Public Function EditSubjectForm(ByVal frm As Form) As Boolean
Dim db As Database, tbl As...
|
by: Dave Boyd |
last post by:
Hi,
I have two very similar forms each with a subform. The main form gets
a few fields from the user and passes this back to a query that the
subform is bound to. The requery is done when the...
|
by: Lyn |
last post by:
Hi,
I am opening a form in Continuous mode to list the records from a recordset
created in the calling form. The recordset object is declared as Public and
is set into the new form's Recordset...
|
by: ultraton |
last post by:
While trying to print a report from Access the user receives the
following error:
Cannot open any more databases.
Okay Help
Does anyone have any ideas about this behavior?
Thank you very...
|
by: Stu |
last post by:
Hi,
I have a combobox who's values change the recordsource of the form.
Within this form, there is a subform, whos records also need to change
pending the value in the combobox. I am able to get...
|
by: kokostik |
last post by:
I did a few searches, but couldn't come up with a clear answer to my
question. So here it is: If I am in an open form (MyForm1), is it
possible to set the RecordSource of an un-opened form...
|
by: Birky |
last post by:
Hello,
I’m hoping you can help me out with two issues I’m having with my code. I have an Access Report named Report_Project_Event_Log which I have calling a Form named “Custom_Code_lookup” which...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |