Solved WhereCondition produces blank form

Dumferling

Member
Local time
Today, 20:15
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?
 
DoCmd.OpenForm "frmCOutsourcing", , , WhereCondition:="ContractID = " & Forms!frmCContractBrowser!ID
 
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?
 
Ah. I knew it would be something incredibly simple and stupid. DataEntry was set to Yes.

Problem solved. Thanks
 
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.
 
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

Back
Top Bottom