Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Visible problem

Status
Not open for further replies.

tamer64

IS-IT--Management
Aug 27, 2007
120
US
Hello Everyone,
I am creating an inventory database and I am going to be using a scanner for this project. I have Mainform (Switchboard) which is unbound and Subform "frm_ScannedTags"(continous form).
I would like it to work like this. When I scan the barcode and if it is equal to the barcode number the image on the mainform would be visible if not it is false.

What I have does not seem to be working. The below code I have inserted into the mainforms OnCurrent event.

[blue]
If Me!frm_ScannedTags.Form!ScannedinvNumber = 941441 Then
Me!Image425.Visible = True
Else
Me!Image425.Visible = False

End If
EndSub[/blue]
 
If I am following correctly...

Try the on Current event of the sub form...


Code:
If Me!ScannedinvNumber = 941441 Then
      Me.Parent!Image425.Visible = True
Else
      Me.Parent!Image425.Visible = False
 
End If
EndSub

It has been a little while since I worked out referencing a control on a parent... I might have it a little off maybe... Me.Parent.Form is needed.

In any case let us know what works if you figure it out or that neither works and I'll play with the syntax if someone doesn't beat me too it.
 
IMHO

put the code in the after update of ScannedinvNumber
 
pwise makes a good point if you are updating the value using the form. If you want the effect on both reviewing and entering a new value, make a procedure for the body of the code and execute it from both the On Current and After update events.
 
lameid :

Since 941441 is a static vaule no need to check on curent

 
pwise:

Me!ScannedinvNumber is not static... So assuming it is a saved value when you navigate the record(s) you MAY want the image to appear or disappear accordingly.

But I think you are right in that the OP definitatley wants the After update event, Good call... The code looked clean so I didn't think about the event when it looked like a main / sub form issue.
 
Thank you all for your replies,

I inserted the code into the After Update event and when the barcode "941441" is scanned the image then becomes visible. The problem I have is when the next item is scanned the image then loses focus and becomes false. As I scan inventory items I need the images associated with the barcode to remain visible.



 
I'm not sure what you mean...

As I scan inventory items I need the images associated with the barcode to remain visible.

I think you have the same code on curent and after update events... I think this code is in the sub form and the image is in the main form.

Because you have an image in the main form for detail in the subform, it is all or nothing. It shows or hides the image based on the events...

If you want the image to be turned on by the scan of a particular image...

I would set the visible property to false on the forms on open event in case the form is saved with the control visible.

Next remove the on current event.

Finally change the code to only set the control visible when the if is true and remove the else block.

If I am guessing wrong about what you want to do or what you have, please clarify.
 
Thank you for being patient with me. I did some work on this last night and got it to work. I inserted the code into the subforms “After Update” event and changed the images visible property to “No” on the main form. The way it works, I scan barcode and it goes into the “T_200_Scan_Collection_Table”. This is a temporary table as it will be deleted once I move into the next office for a new scan.

After all said done, I may have a problem with this code. My inventory is pretty extensive; for example I have about 100 or so monitors and 100 Desktops. So I would hate to list all the barcodes numbers in the code below, that just would not make sense. So I have listed all the monitors into one table and all desktops into another table. What I am thinking is to somehow reference the table the equipment is located in. For example, If I scan “941441” (Desktop) the code below would then check to see if “941441” is in “T_100_Inventory_Desktop_Table” if yes, then the image becomes visible. I think this would be easier then inserting 100 or so barcodes into the “if statement” below.

So, my question is, how do I reference the following inventory tables in the code below?

T_100_Inventory_Desktop_Table
T_101_Inventory_Monitors_Table

[blue]
Private Sub BarCodeScan_AfterUpdate()
Dim strRecordSource
If BarCodeScan = "941441" Then
strRecordSource = "Select * from T_200_Scan_Collection_Table Where"
ScanTag = BarCodeScan
Me.Parent!DeskTopImg.Visible = True
ElseIf BarCodeScan = "948671" Then
strRecordSource = "Select * from T_200_Scan_Collection_Table Where"
ScanTag = BarCodeScan
Me.Parent!MonitorImg.Visible = True

End If
End Sub
[/blue]
 
I would think you would want all your scanned items in one table where you would specify either an item/asset that would have an item type assigned to it. Finally you would have an item type table that would specify a flag that indicates whether the image should appear. You might simplify that some...

From there use dlookup on a query to return the true or false value for the item.
 
I have not worked with the DLookup function before. Baically, I am looking to compare values from one table to another and if they are the same then the image becomes visible. I have kept this code in "after update" field of the subform. When I scan the values there are no error messages. I just cannot get the image to appear-it should work the value I scanned is in both tables so they are equal. Can you take a look at this and tell me whats wrong?

Thanks!
[blue]
Private Sub BarCodeScan_AfterUpdate()
Dim StrScanTag As String
Dim StrNepaNumber As String
StrNepaNumber = Nz(DLookup("[ScanTag]", "[T_200_Scan_Collection_Table]"), "")
StrScanTag = Nz(DLookup("[NepaNumber]", "[T_100_Inventory_Workstations_Table]"), "")
If (StrScanTag = StrNepaNumber) Then
Me.Parent!DesktopImg.Visible = True
End If
End Sub
[/blue]
 
You are missing the third parameter or the criteria... It says find this value.

It looks like your barcode value is text so I made this as an example...


Code:
StrScanTag = Nz(DLookup("[NepaNumber]", "[T_100_Inventory_Workstations_Table]"), "BarcodScanField = "" = " & BarCodeScan & """ ), "")

I am not following the logic of what you are trying to do, you may want different criteria. If you know SQl then think of the criteria as the where clause without the where.

I said Dlookup but a diffent funtion that takes the same parameters may be more appropirate... Dcount. Then you use it directly in your test and do the more work in the query underlying the dcount.
 
Thank You! The third criteria produced the results I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top