accessvba源码
1. 请教Access中的VBA程序代码
添加 DoCmd 对象的 Quit 方法是为了提供在 Microsoft Access for Windows 95 的 Visual Basic 代码中执行 Quit 操作的后向兼容性。建议使用 Application 对象的 Quit 方法来代替。
2. ACCESS中VBA代码问题
你好象对ACCESS中VBA的语法不太了解。你需要主、子窗体联动,不需要这么麻烦,分别设置主、子窗体的记录源,然后在子窗体的“链接主字段”和“链接子字段”的两个属性中设置一下关联的字段就行了。
3. ACCESS数据库VBA代码
第一题 N的最终值相当于经过了I和J的3*4次循环,因为每次循环都只加了1,所以就等于12
第二题 S的值每次循环都只加1,所以只要知道了循环的次数就知道S的值。第一次循环后I的值为1*2=2;第二次循环后I的值变为2+2=4,因为步径值STEP是2,然后再4*2=8;第三次循环后I的值变为8+2=10,然后再10*2=20。因为循环了三次,所以S的值为3,I的值为20.
4. access VBA代码
语句本身没有问题,问题出在不是操作查询上。我试过,如果是操作查询,类似的语句是可以执行的。如:docmd.Runsql
"INSERT
INTO
表2
(
字段a,
字段B
)
SELECT
DISTINCT
表1.字段a,
定额.字段B
FROM
表1
WHERE
(((表1.字段a)="
&
"
'"
&
tuhao
&
"'
"
&
"))
ORDER
BY
表1.字段B"
建议换方式查询。
5. access vba 编程 请高手发个编程代码。谢谢。谢谢、
'计算1到100的所有偶数的和
Function sum100() As Integer
Dim i As Integer
Dim iSum As Integer
iSum = 0
For i = 2 To 100 Step 2
iSum = iSum + i
Next i
sum100 = iSum
MsgBox (iSum)
iSum = 0
i = 2
While (i <= 100)
iSum = iSum + i
i = i + 2
Wend
MsgBox (iSum)
iSum = 0
i = 2
Do Until (i > 100)
iSum = iSum + i
i = i + 2
Loop
MsgBox (iSum)
sum100 = iSum
End Function
'计算出1至200能被3整除的所有数, 并统计个数
Function sum200d3() As Integer
Dim i As Integer
Dim iCount As Integer
Dim sNum As String
iCount = 0
sNum = "1至200能被3整除的所有数:"
For i = 1 To 200
If i Mod 3 = 0 Then
sNum = sNum + Str(i) + ", "
iCount = iCount + 1
End If
Next i
MsgBox (sNum + "个数为:" + Str(iCount))
End Function
'附言: 小鬼, 作业要自己完成啊!
6. Excel调用ACCESS的VBA代码怎么写
提供一种在EXCEL使用代码,连接ACCESS,取得数据的方法,看是不是你要的东西:
SubAC()
DimcnnAsNewConnection
DimrsAsNewRecordset
DimsqlAsString
DimqxAsString
qx="金牛"
cnn.Open"Provider=Microsoft.Ace.OleDB.12.0;dataSource="&ThisWorkbook.Path&"数据库.accdb"
sql="select*from[宏站]where区域='"&qx&"'"
'('"&qx&"'")括号里这段有点BT,一定要这样写才行。
rs.Opensql,cnn
[a1].CopyFromRecordsetrs
EndSub
7. 求access加vba的仓储管理程序,要源代码
更详细的留个邮箱
Attribute VB_Name = "base"
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function BackupData Lib "storage.dll" (ByVal filename As String, ByVal backname As String) As Long
Public Declare Function ResumeData Lib "storage.dll" (ByVal filename As String, ByVal backname As String) As Long
Public Declare Function GetBit Lib "storage.dll" (ByVal bit As Long, ByVal index As Integer) As Integer
Public Declare Function GetBits Lib "storage.dll" (ByVal bit As String, ByVal l As Integer) As Long
Public Declare Function ShowHelp Lib "storage.dll" (ByVal hwnd As Long, ByVal chmname As String, ByVal htmlname As String) As Long
Public Declare Function AddWndMsg Lib "storage.dll" (ByVal hwnd As Long, ByVal msg As Long, ByVal procaddress As Long) As Long
Public Declare Function ClearPrintData Lib "FxPrint.dll" () As Integer
Public Declare Function SetPrintDataWidth Lib "FxPrint.dll" (ByVal width As Integer) As Integer
Public Declare Function AddPrintData Lib "FxPrint.dll" (ByVal data As String) As Integer
Public Declare Function ShowPrint Lib "FxPrint.dll" (ByVal title As String) As Integer
Public Declare Function SaveToFile Lib "FxPrint.dll" () As Integer
Public fMainForm As frmMain '主窗口句柄
Public DataPath As String '数据库路径
Public DataConnectString As String '数据库连接源字符串
Public UserName As String '用户名
Public UserPas As String '用户密码
Public Purview As Long '操作权限
Public 权限类别(16) As Integer '17种权限类别
Public Function ShowPrintDlg(ByVal ado As Adodc, ByVal title As String)
'清除以前的打印数据
ClearPrintData
Dim count As Integer
On Error GoTo quit:
count = ado.Recordset.Fields.count
If count <= 0 Then
MsgBox "没有需打印的数据", vbInformation
Exit Function
End If
'设置打印列宽度
SetPrintDataWidth count
'保存当前位置的状态pos
Dim pos As Long
pos = ado.Recordset.AbsolutePosition
'移到记录最前面
ado.Recordset.MoveFirst
Dim i As Integer
'写入眉头
For i = 0 To count - 1
AddPrintData ado.Recordset.Fields(i).name
Next
'写入数据
While ado.Recordset.EOF = False
For i = 0 To count - 1
If ado.Recordset.Fields(i).ActualSize > 0 Then
AddPrintData ado.Recordset.Fields(i).Value
Else
AddPrintData ""
End If
Next
ado.Recordset.MoveNext
Wend
'恢复以前的记录
ado.Recordset.MoveFirst
If pos > 1 Then ado.Recordset.Move pos - 1
ShowPrint title
Exit Function
quit:
MsgBox "没有打印数据或打印数据未初始化!", vbInformation
End Function
Public Function ShowHelpWnd(index As Long)
If index = 0 Then
ShowHelp fMainForm.hwnd, App.HelpFile, ""
Else
Dim htmlname As String
htmlname = "仓库管理系统.htm/#"
Dim v As String
v = LTrim(Str(index))
Dim i As Integer
For i = 1 To Len(v)
htmlname = htmlname + Mid(v, i, 1)
If i <> Len(v) Then htmlname = htmlname + "_"
Next
ShowHelp fMainForm.hwnd, App.HelpFile, htmlname
End If
End Function
'屏蔽flash右键弹出菜单
Public Function FlashNoRButton(ByVal hwnd As Long, ByVal msg As Long, ByVal wparam As Long, ByVal lparam As Long) As Long
FlashNoRButton = 1
End Function
'删除记录中的所有数据
Public Function DeleteRecordData(Re As Recordset)
If Re.RecordCount <= 0 Then Exit Function
Re.MoveFirst
While Re.EOF = False
Re.Delete
Re.MoveFirst
Wend
End Function
Sub Main()
'检测是否已运行
If App.PrevInstance Then
MsgBox App.title + " 已运行!"
End
End If
'初始化数据库文件路径
DataPath = App.Path + "\storage.mdb"
DataConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataPath + ";Persist Security Info=False" + ";Jet OLEDB:Database Password=prowind"
'启动起始屏
frmSplash.Show vbModal
'启动登陆对话框
Dim fLogin As New frmLogin
fLogin.Show vbModal
If Not fLogin.OK Then
'登录失败,退出应用程序
End
End If
Unload fLogin
'启动主窗口
Set fMainForm = New frmMain
fMainForm.Show
End Sub