解析基于Access數(shù)據(jù)庫的抽獎系統(tǒng)設(shè)計(3)_Access數(shù)據(jù)庫教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:揭秘如何在Access數(shù)據(jù)庫中使用SQL一般在Oracle中使用Sql,在Access中使用很少,不過與Oracle的Sql還是有很多相似之處的。 以下SQL語句在ACCESS XP的查詢中測試通過 建表: Create Table Tab1 ( ID Counter primary key, Name string(20), Age integer, [Date] DateTime); 技巧: 自動增加字段
……
N = 0
cnt = Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value + Me!退休.Value
Do While Me!抽獎數(shù)量.Value > N And Not qrs.EOF And cnt < Me!總數(shù)量.Value
'電科抽獎
’四舍五入確定電科中獎數(shù)
If Me!電科.Value < (Int(((unit1.姓名之Count / cnt1) * Me!總數(shù)量.Value + 0.5))) And N < Me!抽獎數(shù)量.Value And cnt < Me!總數(shù)量.Value Then
If qrs.單位 = "電科" And qrs!批次.Value = 0 Then
Me!電科.Value = Me!電科.Value + 1
qrs.Edit
qrs!獎勵等級.Value = Me!獎勵等級.Value
qrs!批次.Value = Me!批次.Value
qrs.Update
N = N + 1
End If
Else
End If
……
'退休抽獎
cnt = Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value + Me!退休.Value
cnt2= Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value
'剩余數(shù)量分配給退休
If Me!退休.Value < Int((Me!總數(shù)量.Value – cnt2) And N < Me!抽獎數(shù)量.Value And cnt < Me!總數(shù)量.Value Then
If qrs22.單位 = "退休" And qrs!批次.Value = 0 Then
Me!退休.Value = Me!退休.Value + 1
qrs.Edit
qrs22!獎勵等級.Value = Me!獎勵等級.Value
qrs22!批次.Value = Me!批次.Value
qrs22.Update
N = N + 1
End If
Else
End If
……
’判斷是否完成抽獎
cnt = Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value + Me!退休.Value
If cnt = Me!總數(shù)量.Value Then
MsgBox ("抽獎總數(shù)已到。")
Me.可抽獎.Value = 0
Else
MsgBox ("抽獎限制。")
End If
……
N = 0
cnt = Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value + Me!退休.Value
Do While Me!抽獎數(shù)量.Value > N And Not qrs.EOF And cnt < Me!總數(shù)量.Value
'電科抽獎
’四舍五入確定電科中獎數(shù)
If Me!電科.Value < (Int(((unit1.姓名之Count / cnt1) * Me!總數(shù)量.Value + 0.5))) And N < Me!抽獎數(shù)量.Value And cnt < Me!總數(shù)量.Value Then
If qrs.單位 = "電科" And qrs!批次.Value = 0 Then
Me!電科.Value = Me!電科.Value + 1
qrs.Edit
qrs!獎勵等級.Value = Me!獎勵等級.Value
qrs!批次.Value = Me!批次.Value
qrs.Update
N = N + 1
End If
Else
End If
……
'退休抽獎
cnt = Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value + Me!退休.Value
cnt2= Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value
'剩余數(shù)量分配給退休
If Me!退休.Value < Int((Me!總數(shù)量.Value – cnt2) And N < Me!抽獎數(shù)量.Value And cnt < Me!總數(shù)量.Value Then
If qrs22.單位 = "退休" And qrs!批次.Value = 0 Then
Me!退休.Value = Me!退休.Value + 1
qrs.Edit
qrs22!獎勵等級.Value = Me!獎勵等級.Value
qrs22!批次.Value = Me!批次.Value
qrs22.Update
N = N + 1
End If
Else
End If
……
’判斷是否完成抽獎
cnt = Me!電科.Value + Me!電氣.Value + Me!自動化.Value + Me!通信.Value + Me!院辦.Value + Me!退休.Value
If cnt = Me!總數(shù)量.Value Then
MsgBox ("抽獎總數(shù)已到。")
Me.可抽獎.Value = 0
Else
MsgBox ("抽獎限制。")
End If
……
結(jié)論
本系統(tǒng)利用Access數(shù)據(jù)庫,結(jié)合其內(nèi)置VBA語言,探討了系統(tǒng)初始化、抽獎的隨機(jī)性和相對均衡性等關(guān)鍵問題,滿足了抽獎的要求。進(jìn)行適當(dāng)調(diào)整,該系統(tǒng)可以應(yīng)用于多種抽獎場合。
分享:詳解如何遠(yuǎn)程調(diào)用Access數(shù)據(jù)庫使用了TCP/IP,ADO及XML(需要安裝Microsoft XML 4.0。)。分服務(wù)器和客戶端兩部分,服務(wù)器可以多用戶同時連接。遠(yuǎn)程連接Access數(shù)據(jù)庫有很多方法,我以前已經(jīng)比較詳細(xì)的回答過(見下面所列的5種方法),我現(xiàn)在這個例子屬于其中的第3種方法(不需要使用RDS或W
相關(guān)Access數(shù)據(jù)庫教程:
- Access數(shù)據(jù)庫安全策略之ASP式
- 第N次被ACCESS的關(guān)鍵字涮
- Access中用Jet SQL語句刪除表關(guān)系
- Access報表打印如何自動分頁
- Access完成累計余額的計算
- 搭建Access為主的Mdb數(shù)據(jù)庫
- 一句sql更新兩個表并可更新對應(yīng)的字段值具體實現(xiàn)
- MySQL查詢優(yōu)化:連接查詢排序limit(join、order by、limit語句)介紹
- 內(nèi)網(wǎng)ssh/mysql登錄緩慢的解決方法
- 使用準(zhǔn)則進(jìn)行條件查詢--1.4.從窗體中選擇查詢的條件
- 中文Access2000速成教程--1.1 使用“向?qū)А痹O(shè)計數(shù)據(jù)庫
- 中文Access2000速成教程--1.3 在“設(shè)計”視圖中設(shè)計表
- 相關(guān)鏈接:
- 教程說明:
Access數(shù)據(jù)庫教程-解析基于Access數(shù)據(jù)庫的抽獎系統(tǒng)設(shè)計(3)
。