简体   繁体   中英

How to Debug.print into a column or text field in Access?

Is there a way to print out results from Debug.print into a cell on a form instead of just printing in Immediate window? ps. I borrowed this code to generate passwords.

Private Sub Command23_Click()
Dim s As String * 8 'fixed length string with 8 characters
Dim n As Integer
Dim ch As Integer 'the character
For n = 1 To Len(s) 'don't hardcode the length twice
    Do
        ch = Rnd() * 127 'This could be more efficient.
        '48 is '0', 57 is '9', 65 is 'A', 90 is 'Z', 97 is 'a', 122 is 'z'.
    Loop While ch < 48 Or ch > 57 And ch < 65 Or ch > 90 And ch < 97 Or ch > 122
    Mid(s, n, 1) = Chr(ch) 'bit more efficient than concatenation
Next

Debug.Print s
End Sub

Add a text box to the form, and assign s as the text box's Value ...

Debug.Print s
Me!txtDebug.Value = s

If you want to append s to the text box Value (instead of replacing Value each time), you could add the new s value as a new line ...

Me!txtDebug.Value = Me!txtDebug.Value & vbCrLf & s

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM