Solved WhereCondition produces blank form (1 Viewer)

Dumferling

Member
Local time
Today, 20:27
Joined
Apr 28, 2020
Messages
77
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

once i caught a fish alive...
Local time
Tomorrow, 02:27
Joined
May 7, 2009
Messages
13,328
DoCmd.OpenForm "frmCOutsourcing", , , WhereCondition:="ContractID = " & Forms!frmCContractBrowser!ID
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:27
Joined
Sep 21, 2011
Messages
8,547
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, 20:27
Joined
Apr 28, 2020
Messages
77
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, 19:27
Joined
Sep 21, 2011
Messages
8,547
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, 20:27
Joined
Apr 28, 2020
Messages
77
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