sql - Data source to equal input box value -
i have excel file updates access database, realised access database regularly changes location file location inputted input box , used. i've tried case select hasn't been successful, here's have far:
d = inputbox(prompt:="enter file path", title:="please enter file path", default:="file location") select case strptr(d) case 0 exit sub case else dim cnn object dim lngrow long dim lngid long, lr long, upd long dim strid string lr = thisworkbook.worksheets("update").range("bn" & rows.count).end(xlup).row upd = lr - 1 lngrow = 2 set cnn = createobject("adodb.connection") cnn.open "provider=microsoft.ace.oledb.12.0;" & _ "data source=d"
i prefer use filedialog, because better @ preventing invalid input. however, if want use input box, can use dir
function validate resolves existing file path.
d = inputbox(prompt:="enter file path", title:="please enter file path", default:="file location") if dir(d) = vbnullstring 'this not valid path, might want show messagebox. exit sub end if
Comments
Post a Comment