Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error

Status
Not open for further replies.

rokerij

Technical User
Feb 12, 2003
199
I am attempting to split a database that was created by another user. I have a created a database that contains Queries, Forms, reports, modules and macros and linked to tables on the server database. Then the database on the server with tables, modules and macros. the mods and macros are the same on both copies as i was not sure if where they were needed in this type of setup. So this is the "classic" front and back end, right? If not then maybe I have gone ary somewhere. Now when you open either the front or back ends, you get a Compile Error: User - Defined type not defined. Then the code opens with "Dim Currdb as Database" (No quotes). How do I go about defining this and where?
AS ALWAYS, THANK YOU THANK YOU THANK YOU for any and all help you may be able to lend me.
Here is a snapshot of the code:

Public Function Rollit()
'===========================================================
' Function Rollit()
' Mod. 8/31/00 KS
' Function is run at Autoexec. Checks the system date against
' the rollover date in the table UW21SystemScheduler.
' If the rollover target date is greater than 30 days, the
' appearance of the switchboard form remains the same, and
' rollover info appears in a text box only if the "info"
' button is clicked. If within 30 days, the text alert is
' posted, and the caption of the button changes so that
' rollover is initiated. Also true if deadline is overshot
' or the rollover date is within 5 days.
'===========================================================
'MsgBox "Hello from Rollit(). The date is " & Format(Now(), "long date")
Dim TargetDate As Date
Dim currdb As Database
Set currdb = CurrentDb
Dim domesday As Recordset
Set domesday = currdb.OpenRecordset("uw21SystemScheduler", dbOpenTable)
domesday.Index = "PrimaryKey"
domesday.MoveFirst 'Check the current year data
Debug.Print domesday![YearDesignation], domesday![CampaignYear]
Dim topyear As String, nowyear As String
topyear = domesday![CampaignYear]
nowyear = DatePart("YYYY", Now())
TargetDate = domesday![TargetRolloverDate]
Dim resp As Variant
Dim daysleft As Long 'daysleft is difference between Now and target rollover date
daysleft = (DateDiff("d", Now, TargetDate))

S.C. Albertin
Systems Coordinator/Newbie Tech
United Way

Help me to find my way, so that I may help others find theirs...
 
rokerij,
[ol][li]You only need Tables in the backend.[/li]
[li]Make sure you Front End has a reference to the Microsoft DAO 3.6 Object Library.[/li][/ol]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
1) No code usually needed in the Backend
2) In the VBE, menu Tools -> References ...
Tick the Microsoft DAO 3.# Object Library

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

And also dim them like

Dim currdb As DAO.Database
Dim domesday As DAO.Recordset

since ADO may be already present and causing headaches for recordsets!
 
First let me say thank you! Fast responses. I only wish I had time to have tried these attempts earlier. Different error messages now.

Have checked the Microsoft DAO 3.6 Object Library on the Front end machine. Now when opened, recieve:

this highlighted:
Set rst = dbs.OpenRecordset(strSQL)

This DB is set to open up a switchboard.

THANK YOU

S.C. Albertin
Systems Coordinator/Newbie Tech
United Way

Help me to find my way, so that I may help others find theirs...
 
Please let me add...

Code it seems to halt on:


' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [Switchboard Items]"
strSQL = strSQL & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rst.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard page"
Else
While (Not (rst.EOF))
Me("Option" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
rst.MoveNext
Wend
End If

' Close the recordset and the database.
rst.Close
dbs.Close

End Sub

S.C. Albertin
Systems Coordinator/Newbie Tech
United Way

Help me to find my way, so that I may help others find theirs...
 
An attempt to open yet another form, compile error member not found:


Private Sub cmdPostPCBatch_Click()
'---When the operator is satisfied with the totals
' on the batch, the recordset behind this form is
' updated. All records are marked as posted. At this
' point, the original print form is generated.
'---10/20/00
Dim Q As String
Dim Btch As String
Me.Batch.SetFocus
Btch = Me.Batch.Value
Q = "Select * from tblPCEmployees where [Batch] = '" & Btch & "'"
Dim currdb As Database
Set currdb = CurrentDb
Dim thisbatch As Recordset
Set thisbatch = currdb.OpenRecordset(Q)
If Not (thisbatch.BOF And thisbatch.EOF) Then
thisbatch.MoveFirst
Do While Not thisbatch.EOF
thisbatch.Edit (highlighted in blue)
thisbatch![Posted] = True
thisbatch.Update
thisbatch.MoveNext
Loop
Else
MsgBox "There are no records for batch number " & Btch & "!"
Exit Sub
End If
thisbatch.Close
'---print the batch report based on the original query. Note
' that in the report's open event, the record source is
' changed based upon the batch number in the form frmPCBatchEdit

DoCmd.OpenReport "rptPCBatchEditReport", acViewPreview
PCStoresUpdate
End Sub

S.C. Albertin
Systems Coordinator/Newbie Tech
United Way

Help me to find my way, so that I may help others find theirs...
 
Dim thisbatch As [!]DAO.[/!]Recordset

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thank you PHV for the response. I am still running into issues here. This database has resided as a single file on a server for years, and clients would just access the database from their machines using their local software but accessing the actual file over the network on the server. Coming into this I can see this is a bad idea, causing a slow response time from the DB and clogging the network with unnecessary traffic. I am by no means nor do I have any certifications or education a technician, just happen to work at a place that can't afford a tech and I am most familiar with machines.
In splitting the DB I simply created a new DB on the client machine, and importing the Queries, Reports, Forms, Macros. I have made sure the DAO 3.6 is referenced on the client. I linked to the tables on the original DB, leaving it in it's original state, and just linking to the tables.

I am also getting an error when the switchboard loads in the beggining. I can only imagine the issues that may arise as I start to try to use more forms and reports. I have uploaded the code at:


From the earlier post:

Dimmed the "thisbatch" but it did not work, the word edit in the command line

Do While Not thisbatch.EOF
thisbatch.Edit (Highlighted in Blue)
thisbatch![Posted] = True
thisbatch.Update
thisbatch.MoveNext
Loop


I can not begin to thank you all on the help and direction, this can be a trying process.

S.C. Albertin
Systems Coordinator/Newbie Tech
United Way

Help me to find my way, so that I may help others find theirs...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top