Jump to content

Recommended Posts

Posted

Im generating a report on all assets in a room.

 

I select the building from a combo box, this propagates the next combo box with the rooms relevant to the building.

I then pass the room selection to the query -

 

SELECT Assets.AssetID, Assets.AssetDescription, Assets.AssetCategory, Assets.StatusID, Assets.BuildingID, Assets.Building, Assets.Room, Assets.Make, Assets.Model, Assets.ModelNumber, Assets.SerialNumber, Assets.RoomID
FROM Assets
WHERE (((Assets.RoomID)=[Forms]![Audit Tools]![RoomAudit].[Form]![cboProducts_2]))
ORDER BY Assets.RoomID;

 

Now my issue is that "cboProducts_2" displays the descriptive name for the room and not the RoomID needed to generate the results. How can I still select the descriptive name from the combo box but pass the RoomID to the query?

 

I'm positive I have done this before, but for the life of me cant remember (damn you xmas holiday)

Posted

My room selection CBO now lists the two columns - Room Name and Room ID - column 2 (Room ID) is bound.

I have also added some validation to highlight where I'm going wrong.

 

 

When I select the room and click generate report the query runs and then halts saying there is no data to generate the report.

 

SELECT Assets.AssetDescription, Assets.AssetCategory, Assets.Building, Assets.Room, Assets.Make, Assets.Model, Assets.SerialNumber, Assets.BuildingID, Assets.ModelNumber, Assets.RoomID

FROM Assets

WHERE (((Assets.RoomID)=[Forms]![Audit Tools]![RoomAudit]![cboProducts_2].Value));

Posted

Quick trouble shooting: replace:

[Forms]![Audit Tools]![RoomAudit]![cboProducts_2].Value

with a 'hard value' i.e. type in a value that you expect would work. If this returns the expected results. Then when you press the report button do:

MsgBox [Forms]![Audit Tools]![RoomAudit]![cboProducts_2].Value

This show a messagebox displaying what the above code will result to.

  • Thanks 1
Posted
Did you solve it? I seem to remember it being something to do with the "Bound Column" property of the combo box you're using - try increasing/decreasing it by 1 if you still haven't solved it.
Posted

Ha, what a stupid issue!

 

In my main asset entry form the [RoomID] value wasn't being auto populated when the drop-down CBO's were selected - this, a Key ID, was missing from all further queries!

 

After_Update - RoomID=cboProducts_2.value

 

D'Oh!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...