473,409 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

More help with form RecordSource

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
Oct 20 '06 #1
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
Oct 20 '06 #2
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

Oct 20 '06 #3
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
Oct 20 '06 #4
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
Oct 23 '06 #5
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
Oct 24 '06 #6
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
Oct 25 '06 #7
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
Oct 25 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
4
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...
3
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...
4
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...
2
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...
6
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...
7
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...
15
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...
3
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.