dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hi
I can't find what I'm doing wrong
the issues is with this line
The DLookup finds ID_FlNm=2 (the primary key) but when I try use DoCmd.GoToRecord acDataForm, "frmFileName", acGoTo, ID_FlNm the error you cannot go to the specified record.
Many Thanks
Dannielle
I can't find what I'm doing wrong
the issues is with this line
The DLookup finds ID_FlNm=2 (the primary key) but when I try use DoCmd.GoToRecord acDataForm, "frmFileName", acGoTo, ID_FlNm the error you cannot go to the specified record.
VBA Code:
Private Sub cmdGetFile_Click()
Const msoFileDialogFilePicker As Long = 3
Dim objDialog As Object, db As DAO.Database, rst As DAO.Recordset
Dim OrgName_Path As String, OrgName As String, ReturnVal As Integer, IDno As Integer
Dim NewFileName, NewFile_Path As String, FileNo As String, ID_FlNm As Long, Ans As VbMsgBoxResult
Set objDialog = Application.FileDialog(msoFileDialogFilePicker)
StartAgain:
With objDialog
ReturnVal = .Show
If ReturnVal = -1 Then
OrgName_Path = .SelectedItems(1)
Me.txtPathtoEdit.Value = OrgName_Path
OrgName = Extract(OrgName_Path)
ID_FlNm = DLookup("[ID_FlNm]", "tblFileName", "[FileName]='" & OrgName & "'")
If ID_FlNm > 0 Then
Ans = MsgBox("This File Name already exists" & vbNewLine & " YES - Edit File? or" & vbNewLine _
& " NO - ReName File? or" & vbNewLine & " CANCEL - Select New File?", vbYesNoCancel, "File Name Already Exists")
If Ans = vbYes Then
DoCmd.GoToRecord acDataForm, "frmFileName", acGoTo, ID_FlNm
ElseIf Ans = vbNo Then GoTo NewFileName
Dannielle