Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 5th, 2002, 05:38 AM
ECSUK ECSUK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64 ECSUK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 18 sec
Reputation Power: 8
vba assistance required

I am trying to check an event time in a dataset before allowing a user to book a time slot, so as not to double book.

Can anybody tell me how to access a field in a table in Access97/VBA - or even how to access the table for that matter.

I think I need to set a dataset variable and assign the required table to that variable. I tried this but I don't know how to assign a specific dataset to the variable.

Reply With Quote
  #2  
Old June 5th, 2002, 06:52 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
The tables can be updated, retrieved, deleted, have fields added to etc.. by using SQL.

So, write a module function to handle the action:

dim db as database
dim rs as recordset
dim sql as string
set db = CurrentDb()
set rs = db.OpenRecordset("Select slot from table where slot = '" & slot & "';")

if rs.eof then isOkay = true else isOkay = false

Something like that?
__________________
- Sorted!

www.ppfuk.com - Free Photo Sharing

Reply With Quote
  #3  
Old June 9th, 2002, 03:33 PM
ECSUK ECSUK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64 ECSUK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 18 sec
Reputation Power: 8
hmm...I tried that but to no avail.

I am wondering if the following is along the right lines??
---
Private Sub settextboxes(i As Integer)

Dim dbs As Database
Dim qdf As QueryDef
Dim fld As Field
Dim QryStart, QryFinish, xstepval, xmytime, xtmpstart, xtmpfinish, stepval, mytime, tmpstart, tmpfinish As Date
Dim xmytimestr, xmytimestr2, mytimestr, mytimestr2 As String

Set dbs = CurrentDb
Set qdf = dbs.QueryDefs!qryVehiclesBooked

For Each fld In qdf.Fields
If fld.Name = "StartTime" Then
QryStart = fld.Value
End If
Next fld

If StartString <> "00:00:00" Then
If FinishString <> "00:00:00" Then
If Hearse.Value = -1 Then
tmpstart = CDate(StartString)
tmpfinish = CDate(FinishString)
stepval = CDate("00:30:00")

If tdf.Fields(StartTime) = StartString Then
End If
If QryStart >= StartString Then
For mytime = tmpstart To tmpfinish Step stepval
mytimestr = CStr(mytime)
mytimestr2 = Mid(mytimestr, 1, 2)
mytimestr2 = mytimestr2 + Mid(mytimestr, 4, 2)
If ((mytime >= tmpstart) And (mytime < tmpfinish)) Then
Me.Form.Controls("txt" + CStr(i) + CStr(mytimestr2)).BackColor = RGB(0, 0, 0)
End If
Next mytime
End If
End If
End If
End Sub

Reply With Quote
  #4  
Old June 10th, 2002, 03:04 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
Can't really see what you're doing there. Seems a very complicated way of checking for double booking a time slot though.

Reply With Quote
  #5  
Old June 10th, 2002, 06:54 AM
ECSUK ECSUK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64 ECSUK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 18 sec
Reputation Power: 8
Sorry...this is the relevant stuff...

Private Sub settextboxes(i As Integer)

Dim dbs As Database
Dim qdf As QueryDef
Dim QryStart, QryFinish As Date

Set dbs = CurrentDb
Set qdf = dbs.QueryDefs!qryVehiclesBooked

QryStart = qdf.fields(StartTime)
QryStart = qdf.fields(FinishTime)

If not QryStart >= StartString Then
blah blah blah

the problem is assigning a value from the query to a variable

Reply With Quote
  #6  
Old June 10th, 2002, 07:06 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
I've never done that querydef stuff, always used recordsets to obtain the data.

Surely you could just recreate the query in the module and run tests against that?

Reply With Quote
  #7  
Old June 10th, 2002, 10:15 AM
Waltjp's Avatar
Waltjp Waltjp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: NJ, USA
Posts: 91 Waltjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 6
Where are you creating the QueryDef object? I found 2 examples you could pull apart and apply to your code. Both examples can be found at Microsoft Support




Function ParamSPT (NewGroup As String)

Dim MyDb As Database, MyQ As QueryDef
Set MyDb = CurrentDB()

' Create a temporary QueryDef object that is not saved.
Set MyQ = MyDb.CreateQueryDef("")

' Type a connect string using the appropriate values for your
' server.
MyQ.connect = "ODBC;DSN=dsn1;UID=sa;PWD=;DATABASE=test"

' Set ReturnsRecords to false in order to use the Execute method.
MyQ.returnsrecords = False

' Set the SQL property and concatenate the variables.
MyQ.sql = "sp_addgroup" & " " & NewGroup

Debug.Print MyQ.sql
MyQ.Execute
MyQ.Close
MyDb.Close

End Function

==================

Function ParamSPT2(MyParam As String)

Dim MyDb As Database, MyQry As QueryDef, MyRS As Recordset
Set MyDb = CurrentDB()
Set MyQry = MyDb.CreateQueryDef("")

' Type a connect string using the appropriate values for your
' server.
MyQry.connect = "ODBC;DSN=user1;UID=user1;PWD=user1;DATABASE=TEST"

' Set the SQL property and concatenate the variables.
MyQry.SQL = "sp_server_info " & MyParam

MyQry.ReturnsRecords = True
Set MyRS = MyQry.OpenRecordset()
MyRS.MoveFirst

Debug.Print MyRS!attribute_id, MyRS!attribute_name, _
MyRS!attribute_value

MyQry.Close
MyRS.Close
MyDb.Close

End Function


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > vba assistance required


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway