Please help.
I'm trying to use code in the On Current event of a form where a field name DIDA is examined for a 0 value. If it is found, the value of the DIDA field would match the value of the previous autonumered DID field. The default value of DIDA can be set at 0 in the table properties. Would not the code look something like this?
If Me!DIDA.Value = 0 Then
Me!DIDA.Value = Me!DID.Value
End If
It works if I do something like,
Me!DIDA.Value = 23.
Is it because the DID is an autonumber or because I don't seem to have my code straight.
Here is why I am doing this. The hardware is viewed as either a device or component. A device usually holds many components, like drives, printers, scanners, etc. Sometimes, however, a piece of hardware starts out as a component then become a device (or visa versa), like a printer becoming a network printer or a network printer becoming a personal printer. The form can list the devices at a single user's station fairly succinctly as a list of devices. The idea is that the user can see a summary of devices at a station, then expand the devices to see and modify/track the components associated with the devices. It has to be easy to change the hardware between devices and components and stations. If a monitor moves from one location to another, it needs to be tracked quickly.
To get it working, I chose to define a "component" as just another "device" and just have one table for all devices. It works by having an autonumbered Device ID (DID) and a had filled associated Device ID (DIDA). In the form, when both fields have the same number, the Station Form shows the devices in a Device Subform (underlying query only shows data where DID = DIDA). The Component Subform under the Device Subform then shows where the DID <> DIDA). If a component moves from one device to another, the DIDA is changed to the associated device DID. If a component becomes a device, the DIDA is changed to match it's own DID.
Works pretty well otherwise, though wish there were something more elegant.
I'm trying to use code in the On Current event of a form where a field name DIDA is examined for a 0 value. If it is found, the value of the DIDA field would match the value of the previous autonumered DID field. The default value of DIDA can be set at 0 in the table properties. Would not the code look something like this?
If Me!DIDA.Value = 0 Then
Me!DIDA.Value = Me!DID.Value
End If
It works if I do something like,
Me!DIDA.Value = 23.
Is it because the DID is an autonumber or because I don't seem to have my code straight.
Here is why I am doing this. The hardware is viewed as either a device or component. A device usually holds many components, like drives, printers, scanners, etc. Sometimes, however, a piece of hardware starts out as a component then become a device (or visa versa), like a printer becoming a network printer or a network printer becoming a personal printer. The form can list the devices at a single user's station fairly succinctly as a list of devices. The idea is that the user can see a summary of devices at a station, then expand the devices to see and modify/track the components associated with the devices. It has to be easy to change the hardware between devices and components and stations. If a monitor moves from one location to another, it needs to be tracked quickly.
To get it working, I chose to define a "component" as just another "device" and just have one table for all devices. It works by having an autonumbered Device ID (DID) and a had filled associated Device ID (DIDA). In the form, when both fields have the same number, the Station Form shows the devices in a Device Subform (underlying query only shows data where DID = DIDA). The Component Subform under the Device Subform then shows where the DID <> DIDA). If a component moves from one device to another, the DIDA is changed to the associated device DID. If a component becomes a device, the DIDA is changed to match it's own DID.
Works pretty well otherwise, though wish there were something more elegant.