Cmd Btn no longer working

mtagliaferri

Registered User.
Local time
Today, 12:01
Joined
Jul 16, 2006
Messages
550
I am re-designing a DB with new forms, I have created two initial forms and tested them for a long time as fully functional with a command to add a photo on the form; as I have increased the number of new forms suddenly I have realised that the two initial forms which had the cmd button no longer works.
I have no idea of why this is happening, any ideas?

The code that I used is
Code:
Private Sub CmdAddPhoto_Click()

On Error GoTo errHandler
 
    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
 
    With fDialog
       
        fDialog.AllowMultiSelect = False
        fDialog.Title = "Select photo"
        fDialog.Filters.Clear
        fDialog.Filters.Add "JPEG Pictures", "*.jpg"
        fDialog.Filters.Add "BMP Pictures", "*.bmp"
        fDialog.Filters.Add "PNG Pictures", "*.png"
        fDialog.Filters.Add "All files", "*.*"
        fDialog.ButtonName = "Select"
        fDialog.InitialView = msoFileDialogViewLargeIcons
        fDialog.InitialFileName = CurrentProject.Path & "\Documentation\Crew ID Photos\Jpg"
        If fDialog.Show = True Then
        strPath = Trim(fDialog.SelectedItems(1))
        Dim lngID As Long
        lngID = CLng(Me.IDCrewMember.Value)
DoCmd.RunSQL "update tblCrewMember set Picture = '" & strPath & "' where IDCrewMember = " & lngID
Me.Requery
Me.Recordset.FindFirst "[IDCrewMember] = " & lngID

        Else
        End If
    End With
errHandler:
    If (Err.Number = USER_CANC) Then
        Resume Next
    Else
        Exit Sub
    End If
End Sub
 
Sorry, but "the two initial forms which had the cmd button no longer works" doesn't really give us much to work with! What, exactly, happens? Nothing? An error pops? What?

Do other, if any, Command Buttons on these Forms work?

Have you changed the names of anything, along the way, such as Table Names, Field Names, etc.?

Linq ;0)>
 
Hi Linq,
basically nothing happens...
I keep incremental DB as I add or create new forms, I have retrieved the working form from previorus version and copied to the latest DB and as I do so the add Command Button stops launching the event, other Command Buttons on the form seem to be working correctly, for example the Add is not visibile on the form unless the Edit has been pressed.
I have no idea :banghead:
 
What can happen is (especially if you've moved code from one form to another) the button gets disconnected from the event in the code behind the form. If that's the case, the solution is to go into the property sheet and re-click on the ellipsis (...) this should correct the problem....
 
Uncle Gizmo,
can you give more info about ellipsis?
I have deleted the code from the form and added it again, is that what you mean with it?
 
You can see a description of the Ellipsis in this video:- "VBA Beginner - Command Button - Nifty Access" Click on this link:-

What is an ellipsis?

The link should take you to a time index of 3 minutes 11 seconds.

If you click on the ellipsis it will open the code window and you should notice that the cursor indicator will be flashing within the code block related to the command button. If you see that, then you can be pretty sure that the link has been re-established.
 
Thanks for the info, but I am still on a dead end!
I do have the blinking cursor as you can see from the pic.... But still not working
 

Attachments

  • P1.jpg
    P1.jpg
    84.5 KB · Views: 92
Create a new command button on your form. Click on the ellipsis to create the code stub in the code window behind the form. Go to that code window and type the following code in the newly created code stub:-

MsgBox " HELLO "

What Happens?
 
I created the msgbox as you suggested and it works, I then created a brand new command button and copied the code in it but it is not working.
I have checked another form that has a similar command and is not working there neither...
I went on the previous version where the forms were working and double checked there too and both forms are working correctly.
 

Users who are viewing this thread

Back
Top Bottom