Private Sub Command1_Click()
If Not IsNumeric(Me.Text1.Text) Then
  MsgBox "只能输入数字"
End IfEnd Sub

解决方案 »

  1.   

    备份数据库,可以用文件拷贝命令FileCopy 语句示例
    本示例使用 FileCopy 语句来复制文件。示例中假设 SRCFILE 为含有数据的文件。Dim SourceFile, DestinationFile
    SourceFile = "SRCFILE"   ' 指定源文件名。
    DestinationFile = "DESTFILE"   ' 指定目的文件名。
    FileCopy SourceFile, DestinationFile   ' 将源文件的内容复制到目的文件中。FileCopy 语句
          复制一个文件。语法FileCopy source, destinationFileCopy 语句的语法含有以下这些命名参数:部分 描述 
    source 必要参数。字符串表达式,用来表示要被复制的文件名。source 可以包含目录或文件夹、以及驱动器。 
    destination 必要参数。字符串表达式,用来指定要复制的目地文件名。destination 可以包含目录或文件夹、以及驱动器。 
    说明如果想要对一个已打开的文件使用 FileCopy 语句,则会产生错误。
      

  2.   

    谢了,可是在key press事件中如何限制非数字的输入呢?
      

  3.   

    Public Function F_InputNumeric(KeyAscii As Integer) As Integer
    '*** 目的:通用过程 输入时只能接受的数字和“.”
        Select Case KeyAscii
            Case 48 To 57, 8
                F_InputNumeric = KeyAscii
            Case Else
                F_InputNumeric = 0
        End Select
    End Function
    在key Press 中调用 形式如 keyascii=f_inputnumeric(keyascii)
      

  4.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Print KeyAscii
    If KeyAscii < 49 Or KeyAscii > 60 Then
       If KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii <> 13 Then
      MsgBox "必须为数字"
    End If
    End If
    End Sub
      

  5.   

    错了,这样
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Print KeyAscii
    If KeyAscii < 48 Or KeyAscii > 60 Then
       If KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii <> 13 Then
      MsgBox "必须为数字"
    End If
    End If
    End Sub
      

  6.   

    http://www.csdn.net/expert/topic/775/775597.xml?temp=.8942987function chkdata(intData as integer,optional strString as string="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")as integer
    chkdata=iif( instr(strstring,ucase(asc(intdata)))=0 ,0,intdata)
    end functionPrivate Sub Text1_KeyPress(KeyAscii As Integer)
       if not KeyAscii=13 then keyascii=chkdata(keyascii)
    End Sub差不多象上面的吧
    如果需要别的字符写在strstring参数中自己看就是了
    部需要注释了吧?
      

  7.   

    private sub text1_keypress(keyascii as interge)
       if keyascii<0  or keyascii>9 then
       keyascii=0
    end if 
    end sub
    类似的 ,记不清楚了
      

  8.   

    在打开该数据库前,比如LOAD 窗体事件时用FILECOPY 命令试试