Reinstalando todo...
If Me!cboEjemplo.ListCount = 1 Then
Me!cboEjemplo= Me!cboEjemplo.ItemData(0)
End If
Public Function GetUDT_ToBlank() as CualquierUDT
End Function
Sub ControlarRespuestaInputBox()
Dim Respuesta As Variant
Respuesta = InputBox("Escribe (o no) algo en el InputBox")
' Se utiliza el método VBA oculto StrPtr para obtener el puntero de una variable tipo String
' si devuelve 0 es que el puntero es un Null, así que no ha habido respuesta positiva
If StrPtr(Respuesta) = 0 Then
MsgBox "Se ha pulsado Cancelar o se ha cerrado el mensaje con la 'X'", vbInformation
ElseIf Len(Respuesta) = 0 Then
MsgBox "No se ha escrito nada, pero se ha pulsado Aceptar", vbInformation
Else
MsgBox "En el InputBox se ha escrito: " & Respuesta, vbInformation
End If
End Sub
Function TestUnidades()
Dim objDrv As Object
Dim strMsg As String
For Each objDrv In CreateObject("Scripting.FileSystemObject").Drives
Select Case objDrv.DriveType
Case 0: strMsg = strMsg & vbNewLine & objDrv.DriveLetter & ": Unknown"
Case 1: strMsg = strMsg & vbNewLine & objDrv.DriveLetter & ": Removable Drive"
Case 2: strMsg = strMsg & vbNewLine & objDrv.DriveLetter & ": Hard Disk Drive"
Case 3: strMsg = strMsg & vbNewLine & objDrv.DriveLetter & ": Network Drive"
Case 4: strMsg = strMsg & vbNewLine & objDrv.DriveLetter & ": CDROM Drive"
Case 5: strMsg = strMsg & vbNewLine & objDrv.DriveLetter & ": RAM Disk Drive"
End Select
Next
Debug.Print strMsg
Set objDrv = Nothing
End Function
? IsControlSelected (Forms!Customers, "CompanyName")
Function IsControlSelected(frm As Form, strControlName As String) As Boolean
Dim intI As Integer, ctl As Control
If frm.CurrentView <> 0 Then
' Form is not in Design view.
Exit Function
Else
For intI = 0 To frm.Count - 1
Set ctl = frm(intI)
If ctl.InSelection = True Then
' Is desired control selected?
If UCase(ctl.Name) = UCase(strControlName) Then
IsControlSelected = True
Exit Function
End If
Else
IsControlSelected = False
End If
Next intI
End If
End Function
Function ControlesSeleccionados(frm As Form) As String
Dim strTmp As String
Dim ctl As Control
For Each ctl In frm.Controls
If ctl.InSelection Then
strTmp = strTmp & ", " & Chr(34) & ctl.Name & Chr(34)
End If
Next ctl
ControlesSeleccionados = Trim(Mid(strTmp, 2))
End Function
) para copiar un texto dado en el portapapeles. Apunta 2 soluciones: una mediante API y otra mediante MSForms.DataObject.
Public Function RT_CopyToClip(ByVal Expresion As String)
Const DATAOBJECT_BINDING As String = "new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}"
With CreateObject(DATAOBJECT_BINDING)
.SetText Expresion
.PutInClipboard
End With
End Function
Dim dbs As DAO.Database
Set dbs = CurrentDb
dbs.Execute "UPDATE Clientes SET Comercial = 'Xavi' WHERE Zona = 'A'", dbFailOnError
MsgBox "Actualización de datos realizada. Registros afectados: " & dbs.RecordsAffected, vbInformation
dbs.Close
Set dbs = Nothing