Add a date to a textbox with a button.

Eastman

New Member
Joined
Mar 18, 2011
Messages
2
In a form, I am trying to add the current date to a textbox when a button is clicked on the form. I thought this was easy but I keep getting different errors.

Here is the code.

Code:
Function Import_Credit()



Dim appExcel As Excel.Application
Dim wb As Excel.Workbook
Dim sh As Excel.Worksheet
Dim strValue As String
   
  
   
   On Error GoTo ImportXLSheetsAsTables_Error
Set appExcel = CreateObject("Excel.Application")
Set wb = appExcel.Workbooks.Open("\\cdnbwdata1\cardmgmt\Card Management Database Project\CREDIT.xls")
For Each sh In wb.Sheets
Debug.Print sh.Name
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "" & sh.Name, "\\cdnbwdata1\cardmgmt\Card Management Database Project\CREDIT.xls", True, sh.Name & "!"
Next
wb.Close
appExcel.Quit

MsgBox "Import Complete!"


 
    
   On Error GoTo 0
   Exit Function
ImportXLSheetsAsTables_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ImportXLSheetsAsTables of Module Module9"
End Function

The textbox is bound to a table where the dates will be stored.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Welcome to the board Eastman.

You are probably running into errors because the textbox is bound. Updating the record would probably be what you want. I am not super proficient with SQL strings to be able to help you, but wanted to point you in a direction to do some research in case you don't get a response. The weekend is fast approaching!
 
Upvote 0
What is the code you posted meant to do?

I don't see anything involving putting a date in a textbox/field.:eek:
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,716
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top