Solved WhereCondition produces blank form (1 Viewer)

Dumferling

Member
Local time
Today, 17:50
Joined
Apr 28, 2020
Messages
102
This should work but it produces a blank form and I just can't see why. I am opening a popup form with additional information by clicking on a CommandButton. The OpenForm line looks like this: DoCmd.OpenForm "frmCOutsourcing", , , WhereCondition:="ContractID = '" & Forms!frmCContractBrowser!ID & "'"

ContractID is on the popup form and the other reference is on the main form. If I watch them they both contain the same variable (308 in this case) (ContractID is the autonumber and ID is a number field - the two underlying tables are related by these fields). The form opens fine and the condition evaluates without an error but it just opens a blank form with a "0" in the ContractID.

The underlying SQL query is:
SELECT tblCOutsourcing.ID, tblCOutsourcing.ContractID, tblCOutsourcing.FunctionOutsourced, tblCOutsourcing.OutsourceType, tblCOutsourcing.OutsourceTo, tblCOutsourcing.DateAdded
FROM tblCOutsourcing;

I have tried various permutations of this but they all end up the same way. Am I doing something obviously wrong?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:50
Joined
May 7, 2009
Messages
19,175
DoCmd.OpenForm "frmCOutsourcing", , , WhereCondition:="ContractID = " & Forms!frmCContractBrowser!ID
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:50
Joined
Sep 21, 2011
Messages
14,059
Firstly, you do not use quotes with numerics, so remove the single quotes for ContractID.
Hopefully the popup form is not set to Data Entry = Yes, as that will always give you a blank form?
 

Dumferling

Member
Local time
Today, 17:50
Joined
Apr 28, 2020
Messages
102
Ah. I knew it would be something incredibly simple and stupid. DataEntry was set to Yes.

Problem solved. Thanks
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:50
Joined
Sep 21, 2011
Messages
14,059
Ah. I knew it would be something incredibly simple and stupid. DataEntry was set to Yes.

Problem solved. Thanks
You still have the quotes issue? I would have thought that would produced 'data type mismatch'?
I am assuming ID is numeric as that is how I name my keys.
 

Dumferling

Member
Local time
Today, 17:50
Joined
Apr 28, 2020
Messages
102
I changed that back as suggested. I had it like that originally and then tried different syntax in case I was making a mistake. ID is numeric and it works smoothly now. Thanks
 

Users who are viewing this thread

Top Bottom