|
-
Oct 20th, 2000, 08:36 AM
#1
Thread Starter
Evil Genius
Hi everyone, small problem. I want to make a support / call logging program for myself to help me at work, but am stuck on the very first part!!!
As soon as access loads, a form is opened up. This form, when run, creates a table called "Week Ending :" & Date -where date is always the last day / Friday of the week.
Please can you tell me where the below is going wrong? I am trying to create a new table with Access DAO with 2 column headings.
Thank you every one 
Code:
Private Sub Form_Load()
Dim Newfld As Variant, Newfld2 As Variant
CurrentDb.CreateTableDef (Date)
Set Newfld = CurrentDb.TableDefs("Week Ending :" & Date).CreateField("Customer", "text")
Set Newfld2 = CurrentDb.TableDefs("Week Ending :" & Date).CreateField("Support Issue", "text")
Set Newfld = Nothing
Set Newfld2 = Nothing
End Sub
-
Oct 20th, 2000, 08:52 AM
#2
Fanatic Member
ACCESS
why you dont try this code before use de access command.
Dim appAccess As Access.Application
Dim sPath As String
sPath = "path"
Set appAccess = _
CreateObject("Access.Application")
appAccess.OpenCurrentDatabase sPath
appAccess.DoCmd.OpenForm "Main"
One thing: Do you know how can i create and EXE file in ACCESS or something better than a MDE?
-
Oct 20th, 2000, 09:00 AM
#3
Thread Starter
Evil Genius
Ok, sorry, should have put that ...
Thank you Luis, I should have explained better.
This bit I am Ok with, thank you for the answer though. I have just taken the part of my code which has the error in to show as an example.
As to your question, MDE is the highest level. If you want this to appear as an exe file, you can hide all of the menus, toolbars etc by going to the tools menu and selectijng the startup option.
[Edited by alex_read on 10-20-2000 at 10:06 AM]
-
Oct 20th, 2000, 06:43 PM
#4
Junior Member
This will do the job. It creates a table name todays date (ie 10202000 for Oct. 20, 2000).
Private Sub Form_Load()
Dim dbs As Database
Dim strTableName As String
Set dbs = CurrentDb
strTableName = Month(Date) & Day(Date) & Year(Date)
dbs.Execute "CREATE TABLE " & strTableName & " (Customer TEXT, Support_Issue TEXT );"
dbs.Close
End Sub
-
Oct 20th, 2000, 07:29 PM
#5
Junior Member
Oops, don't forget the error checking!! As for a table being named "Week Ending: 10202000", I do not belive that is a valid table name. You should be able to name it "Week_Ending_10202000" though; but to me less typing is better so I would prefer the 10202000!!
Private Sub Form_Load()
Dim dbs As Database
Dim strTableName As String
On Error GoTo getout
Set dbs = CurrentDb
strTableName = Month(Date) & Day(Date) & Year(Date)
dbs.Execute "CREATE TABLE " & strTableName & " (Customer TEXT, Support_Issue TEXT );"
dbs.Close
getout:
If Err = 3010 Then
MsgBox "Table " & strTableName & " exists."
dbs.Close
Exit Sub
Else
MsgBox "Table " & strTableName & " created."
End If
End Sub
-
Oct 23rd, 2000, 03:02 AM
#6
Thread Starter
Evil Genius
Wow
Thank you for everyones help. Worked a treat !
-
Oct 23rd, 2000, 03:44 AM
#7
Thread Starter
Evil Genius
A big thank you !
Thank you everyone for the responses. Just to be aawkward (because it's sokmething I'm good at) Is there any way to split the date up please?
I am trying :
Code:
Dim strTableName As String
strTableName = "Week Ending_" & Month(Date) & "_" & Day(Date) & "_" & Year(Date)
CurrentDb.Execute "CREATE TABLE " & strTableName & " (Customer TEXT, Support_Issue TEXT );"
CurrentDb.Close
without much luck. If possible, can you have 10.01.00 or 10/01/00 or 10_01_00 etc?
Thank you once again!
-
Nov 20th, 2000, 09:00 PM
#8
Junior Member
This will give you the format of mm_dd_yy
strTableName = Month(Date) & "_" & Day(Date) & "_" & Mid(Year(Date), 3, 4)
-
Nov 21st, 2000, 04:04 AM
#9
Thread Starter
Evil Genius
Thank you dangr, I have it now
-
Nov 21st, 2000, 12:17 PM
#10
Why do you have to split the date when you can use Format function which will do it for you:
strTableName = Format(Date, "mm_dd_yyyy")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|