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!

Options for data entry? 1

Status
Not open for further replies.

Mayhem9

Technical User
Dec 19, 2009
155
AU
Hmmm - not exactly sure how best to describe this:

In another post, I sought help on displaying an image in a form, using the picture name in the table. I have this working well now and I am unsure of the ways in which I can enter the image name, other than putting the textbox into the form and entering the image name as I do for the other variables I collect.

Essentially, the image name is not something that needs to be seen, just like the auto number that I used as the primary key.

I have not used queries to update tables before and I’m not sure I actually know how best to use them anyway but I am guessing that this may be an option. I was thinking of generating another form that could be accessed via an “add picture” button in the main form. If I were to go with this sort of approach, is there any way to hide the button if a picture exists?

Any comments and suggestions welcomed.

Thanks,
Darren
 
To set a button to visible if the picture name is blank, use the form's On Current event and something like this:

Code:
Me.cmdButtonNameHere.Visible = (Len(Me.txtPictureName & "")=0)

Bob Larson
Free Access Tutorials and Samples:
 
Hi Bob,

Thanks for the code. I am getting an error with the "PictureName" component.

The name I used is for the field name that contains the path to the picture (ImagePath).

The error messages states "Method or data member not found."

I have tried using the unbound image which is used to display the image in the form (ImageFrame), with the same result. I didn't expect that to work but I thought I would try some things before coming back here.

Cheers,
Darren
 
Hi Bob,

Sorry - I obviously didn't explain what I had done sufficiently enough. I had edited your code to include the actual names I am using. I have several functions under the On Current event, so I am using sub events. Here is the code I entered:

Code:
Private Sub subD()
Me.cmdAddImage.Visible = (Len(Me.txtImageFrame & "") = 0)
End Sub

AddImage is the name of the button that will open the form to add an image
ImagePath is the fields in the table into which the image name is stored

The image is displayed on the form using an unbound image called ImageFrame, using the following code:

Code:
Private Sub subA()

    On Error Resume Next
    If Not Trim(Me!ImagePath & " ") = "" Then
      Me![ImageFrame].Picture = Me![ImagePath]
    Else
      Me![ImageFrame].Picture = "D:\Tools\Images\No_Pic.gif"
    End If
    
End Sub

Cheers,
Darren
 
What about this ?
Code:
Private Sub subD()
Me!cmdAddImage.Visible = (Trim(Me!ImagePath & "") = "")
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV,

New error with this code:

Run-time error ‘2465’:

Microsoft Office Access can’t find the field ‘cmdAddImage’ referred to in your expression.

The reason will be that AddImage is the name of a button, not a field. The aim is to have a pop-up window open when the button is clicked, so the ImagePath can be entered.

Cheers,
Darren
 
So, use the real name of the control:
Me!AddImage.Visible = (Trim(Me!ImagePath & "") = "")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV,

It actually took me a few minutes to spot the difference between the two codes. I am extremely inexperienced with VB code, so I have no idea what the change actually did.

I'd like to know if you have a moment to explain. The code works fine by the way!

Cheers,
Darren
 
I have no idea what the change actually did
PHV said:
So, use the real name of the control

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The real names were there all the time - the only difference between the code that worked and the code that didn't is "cmd".

So that wasn't suppose to be there?
 
Thanks - I wasn't sure if cmd was suppose to be in the code, as the original example was cmdButtonNameHere.

As such, I thought it was only ButtonNameHere that was the name. I thought cmd might have been command, which sort of made sense given we are talking about a button.

Sometimes, what appears to be simple for those who use access is confusing for complete novices like me.

I do appreciate your help though, I think I am making some progress here!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top