解析基于Access数据库的抽奖系统设计(3)_Access数据库教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:揭秘如何在Access数据库中使用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!抽奖数量.Value > N And Not qrs.EOF And cnt < Me!总数量.Value
 '电科抽奖
 ’四舍五入确定电科中奖数

 If Me!电科.Value < (Int(((unit1.姓名之Count / cnt1) * Me!总数量.Value + 0.5))) And N < Me!抽奖数量.Value And cnt < Me!总数量.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
 '剩余数量分配给退休
 If Me!退休.Value < Int((Me!总数量.Value – cnt2) And N < Me!抽奖数量.Value And cnt < Me!总数量.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!总数量.Value Then
  MsgBox ("抽奖总数已到。")
  Me.可抽奖.Value = 0
 Else
  MsgBox ("抽奖限制。")
 End If
 ……

  结论

  本系统利用Access数据库,结合其内置VBA语言,探讨了系统初始化、抽奖的随机性和相对均衡性等关键问题,满足了抽奖的要求。进行适当调整,该系统可以应用于多种抽奖场合。

分享:详解如何远程调用Access数据库
使用了TCP/IP,ADO及XML(需要安装Microsoft XML 4.0。)。分服务器和客户端两部分,服务器可以多用户同时连接。远程连接Access数据库有很多方法,我以前已经比较详细的回答过(见下面所列的5种方法),我现在这个例子属于其中的第3种方法(不需要使用RDS或W

共3页上一页123下一页
来源:模板无忧//所属分类:Access数据库教程/更新时间:2010-02-01
相关Access数据库教程