HOLA BUENAS LAS TENGAN (SEAN DIAS O NOCHES)
BUENO HE AKI PRACTICANDO UN POCO SE ME OCURRIO TRATAR DE EMPEZAR CON BASE DE DATOS
ENTONCES SEGUN ENLACE MI BASE DE DATOS
CON TODOS MIS CONTROLES PERO NO LOGRO HACER UNA CONSULTA SEGUN HE TRATADO CON ESTO
'ESTO VA EN EL KEYPRESS DEL TXTCLIENTE.TEXT
TXTCLIENTE_KEYPRESS(KEYASCII AS INTEGER)
IF KEYASCII=13 THEN ' SI LA TECLA PRESIONADA ES IGUAL A= 13(ENTER )ENTONCES
SELECT*FROM CLIENTES WHERE CLAVE=&TXTCLIENTE.TEXT
WITH ADOCLIENTES
.RECORDSOURCE
.CLEAR
WND WITH
ELSE
END IF
PERO NO REALIZA LA CONSULTA SEGUN YO QUIERO QUE CUANDO EL CLIENTE PONGA X NUMERO EN EL TXTCLIENTE.TEXT Y DE ENTER REALIZE LA BUSQUEDA EN BASE A LA CLABE
TODOS MODOS LES PONGO EL LINK DEL PROYECTO COMPLETO ESPERO ME PUEDAN AYUDAR
http://mx.geocities.com/kaiserkalamar/sistemch.zip
GRACIAS, SALU2
No te compliques.. haslo por codifo..
Dim RsClientes As New Recordset
RsPaises.Open "Select * From Clientes Where Clave='"& Text1.Text &"' Order By Pais", DBConex, adOpenStatic, adLockOptimistic
Una ves que tengas abierto la table pues llenas en un ListView, por ejemplo..
Mejor Prueba con un ListView. Es lo mejor. A lar larga yo prefiero as.i
With Form1
.ListView1.ListItems.Clear
.ListView1.ColumnHeaders.Clear
.ListView1.ColumnHeaders.Add 1, "A", "Codigo", 1300, 0
.ListView1.ColumnHeaders.Add 2, "B", "Fecha", 1100, 0
.ListView1.ColumnHeaders.Add 3, "C", "Cliente", 2300, 0
.ListView1.ColumnHeaders.Add 4, "D", "Teléfonos", 1500, 0
.ListView1.ColumnHeaders.Add 5, "E", "Ciudad", 1000, 0
.ListView1.View = lvwReport
Dim RsClientes As New Recordset
RsClientes.Open "Select * From Clientes Where Codigo like '%" & Text1.Text & "%'", DBConex, adOpenStatic, adLockOptimistic
If RsClientes.RecordCount > 0 Then
RsClientes.MoveFirst
For i = 1 To RsClientes.RecordCount
Set list_item = .ListView1.ListItems.Add(, , RsClientes!Codigo)
list_item.SubItems(1) = IIf(IsNull(RsClientes!Cliente), "", RsClientes!Cliente)
list_item.SubItems(1) = IIf(IsNull(RsClientes!Telefono), "", RsClientes!Telefono)
list_item.SubItems(1) = IIf(IsNull(RsClientes!Ciudad), "", RsClientes!Ciudad)
RsClientes.MoveNext
Next i
Else
Msgbox "Comentario", VBExClamation, "Titulo"
End If
RsClientes.Close
End With
Considerar esoto....
list_item.SubItems(1) = IIf(IsNull(RsClientes!Cliente), "", RsClientes!Cliente)
list_item.SubItems(2) = IIf(IsNull(RsClientes!Telefono), "", RsClientes!Telefono)
list_item.SubItems(3) = IIf(IsNull(RsClientes!Ciudad), "", RsClientes!Ciudad)
muchas gracias pero no logro que funcione
en los ejemplos que me pusieron no he logrado entender que es un rocordset
en el codigo este segun se declara rsclientes como un recordset
y luego que se su pone que es el rspaises un ado data control???? o devera ser la variable rsclientes??
y eso de order by pais? (ordenar por pais? y lo de DBconex
lo de adopenstatic y lo de adlockoptimistic
Dim RsClientes As New Recordset
RsPaises.Open "Select * From Clientes Where Clave='"& Text1.Text &"' Order By Pais", DBConex, adOpenStatic, adLockOptimistic
por cierto ya probe el codigo segun com mi base pero no hago que funciones
mmm aparte de enlazar la base de datos hay que hacer algo mas???
este es mi proyecto
http://mx.geocities.com/kaiserkalamar/sistemch.zip
o el codigo de la form.:
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmCrear
Caption = "Form2"
ClientHeight = 10485
ClientLeft = 60
ClientTop = 450
ClientWidth = 13860
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 10485
ScaleWidth = 13860
WindowState = 2 'Maximized
Begin VB.Frame Frame1
Caption = "Facturacion"
Height = 9135
Left = 240
TabIndex = 0
Top = 360
Width = 12135
Begin MSAdodcLib.Adodc AdoClientes
Height = 330
Left = 240
Top = 3000
Width = 4680
_ExtentX = 8255
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Z:\sistemch\datos\Syst.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Z:\sistemch\datos\Syst.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select*from clientes where clave"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox tXTcPOSTAL
DataField = "codigopostal"
DataSource = "AdoCLIENTES"
Height = 285
Left = 2280
TabIndex = 38
Text = "Text1"
Top = 2160
Width = 3015
End
Begin MSDataGridLib.DataGrid DATACONCEPTOS
Height = 3735
Left = 480
TabIndex = 37
Top = 4800
Width = 9495
_ExtentX = 16748
_ExtentY = 6588
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "C o n c e p t o s "
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2058
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2058
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.Frame FroPciones
Caption = "Cambiar Fecha.:"
Height = 4815
Left = 5520
TabIndex = 32
Top = 120
Width = 6495
Begin VB.CommandButton Command3
Caption = "&Cancelar"
Height = 495
Left = 4560
TabIndex = 35
Top = 1560
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "&Aceptar"
Height = 495
Left = 4560
TabIndex = 34
Top = 840
Width = 1695
End
Begin VB.TextBox TXTNfecha
BeginProperty DataFormat
Type = 1
Format = "dd/MM/yyyy"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2058
SubFormatType = 3
EndProperty
Height = 495
Left = 1920
TabIndex = 33
Top = 720
Width = 2535
End
Begin VB.Label Label15
Caption = "Nueva Fecha.:"
Height = 375
Left = 600
TabIndex = 36
Top = 840
Width = 1095
End
End
Begin VB.Frame Frame3
Height = 2175
Left = 8040
TabIndex = 24
Top = 240
Width = 3855
Begin VB.TextBox TXTHora
Height = 375
Left = 1920
TabIndex = 30
Text = "Text6"
Top = 1080
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "Cambiar Fecha"
Height = 375
Left = 2160
TabIndex = 29
ToolTipText = "Puede Cambiar el numero de Folio o la fecha del sistema!!"
Top = 1560
Width = 1455
End
Begin VB.TextBox TXTFEcha
Height = 285
Left = 1920
TabIndex = 27
Text = "Text7"
Top = 720
Width = 1455
End
Begin VB.TextBox TXTFolio
Height = 375
Left = 1920
TabIndex = 25
Text = "Text6"
Top = 240
Width = 1455
End
Begin VB.Label Label14
Caption = "Hora.:"
Height = 255
Left = 1320
TabIndex = 31
Top = 1200
Width = 495
End
Begin VB.Label Label13
Caption = "Fecha.:"
Height = 375
Left = 1320
TabIndex = 28
Top = 720
Width = 615
End
Begin VB.Label Label12
Caption = "Folio Factura"
Height = 375
Left = 840
TabIndex = 26
Top = 240
Width = 1095
End
End
Begin VB.Frame Frame2
Caption = "Detalle a Facturar"
Height = 6015
Left = 0
TabIndex = 11
Top = 3480
Width = 11655
Begin VB.CommandButton Command4
Caption = "&Agregar"
Height = 375
Left = 9960
TabIndex = 20
Top = 600
Width = 975
End
Begin VB.TextBox TxtSUBtotal
BeginProperty DataFormat
Type = 1
Format = """$""#,##0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2058
SubFormatType = 2
EndProperty
Height = 285
Left = 8520
TabIndex = 21
Top = 600
Width = 1215
End
Begin VB.TextBox TxtPrecio
BeginProperty DataFormat
Type = 1
Format = """$""#,##0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2058
SubFormatType = 2
EndProperty
Height = 285
Left = 7320
TabIndex = 19
Top = 600
Width = 975
End
Begin VB.TextBox TxtDescripcion
Height = 285
Left = 2520
TabIndex = 14
Top = 600
Width = 4455
End
Begin VB.TextBox TXTUnidad
Height = 285
Left = 1320
TabIndex = 13
Top = 600
Width = 975
End
Begin VB.TextBox TxtCantidad
BeginProperty DataFormat
Type = 1
Format = "#,##0.00;(#,##0.00)"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2058
SubFormatType = 1
EndProperty
Height = 285
Left = 360
TabIndex = 12
Top = 600
Width = 855
End
Begin VB.Line Line1
X1 = 240
X2 = 11400
Y1 = 1080
Y2 = 1080
End
Begin VB.Label Label11
Caption = "Total"
Height = 255
Left = 8640
TabIndex = 23
Top = 240
Width = 975
End
Begin VB.Label Label10
Caption = "Precio"
Height = 255
Left = 7560
TabIndex = 22
Top = 240
Width = 495
End
Begin VB.Label Label9
Caption = "Descripcion"
Height = 255
Left = 2640
TabIndex = 18
Top = 240
Width = 4575
End
Begin VB.Label Label7
Caption = "Unidad"
Height = 255
Left = 1440
TabIndex = 16
Top = 240
Width = 615
End
Begin VB.Label Label6
Caption = "Cantidad"
Height = 255
Left = 360
TabIndex = 15
Top = 240
Width = 855
End
End
Begin VB.TextBox TXTRFC
DataField = "RFC"
DataSource = "AdoCLIENTES"
Height = 285
Left = 2280
TabIndex = 9
Text = "Text3"
Top = 2520
Width = 3375
End
Begin VB.TextBox TXTCUidadEDO
DataField = "direccion2"
DataSource = "AdoCLIENTES"
Height = 285
Left = 2280
TabIndex = 7
Text = "Text2"
Top = 1800
Width = 5175
End
Begin VB.TextBox TXTDireccion
DataField = "direccion"
DataSource = "AdoCLIENTES"
Height = 285
Left = 2280
TabIndex = 5
Text = "Text1"
Top = 1440
Width = 5175
End
Begin VB.TextBox TXTNCLiente
DataField = "nombre"
DataSource = "AdoCLIENTES"
Height = 285
Left = 2280
TabIndex = 3
Text = "Text1"
Top = 1080
Width = 5175
End
Begin VB.TextBox TxtCliente
DataField = "clave"
DataSource = "AdoCLIENTES"
Height = 285
Left = 1560
TabIndex = 1
Text = "Text1"
Top = 600
Width = 1335
End
Begin MSDataListLib.DataList DataList1
DataField = "clave"
DataSource = "Adodc1"
Height = 450
Left = 3360
TabIndex = 40
Top = 360
Width = 1575
_ExtentX = 2778
_ExtentY = 794
_Version = 393216
MatchEntry = -1 'True
End
Begin VB.Label Label16
Caption = "Codigo Postal"
Height = 255
Left = 480
TabIndex = 39
Top = 2160
Width = 1575
End
Begin VB.Label Label5
Caption = "RFC.:"
Height = 255
Left = 840
TabIndex = 10
Top = 2520
Width = 1215
End
Begin VB.Label Label4
Caption = "Cuidad Y Estado"
Height = 255
Left = 720
TabIndex = 8
Top = 1800
Width = 1215
End
Begin VB.Label Label3
Caption = "Direccion"
Height = 255
Left = 720
TabIndex = 6
Top = 1440
Width = 1335
End
Begin VB.Label Label2
Caption = "Nombre del cliente"
Height = 375
Left = 720
TabIndex = 4
Top = 1080
Width = 1455
End
Begin VB.Label Label1
Caption = "Clave Cliente"
Height = 255
Left = 240
TabIndex = 2
Top = 600
Width = 1095
End
End
Begin VB.Label Label8
Caption = "Label8"
Height = 495
Left = 4080
TabIndex = 17
Top = 4080
Width = 1215
End
End
Attribute VB_Name = "frmCrear"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'TIENDA19 ACUERDA ELIEL DE STN BNC
Private Sub Command1_Click()
FroPciones.Visible = True
End Sub
Private Sub Command3_Click()
FroPciones.Visible = False
End Sub
Private Sub Command4_Click()
MsgBox "se ha agregado la entrada", vbCritical, "----"
End Sub
Private Sub Form_Load()
TXTFEcha = Date
TXTHora = Time
FroPciones.Visible = False
End Sub
Private Sub TxtCantidad_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
End If
End Sub
Private Sub TxtCliente_Change()
'On Error GoTo error
Dim STRQUERY As String
Dim RsClientes As New Recordset
Dim AdoClien As New Recordset
'If KeyAscii = 13 Then
' aki debe buscar en la base si existe el cliente si no entonces?? inche kalamar
'STRQUERY = "SELECT * FROM CLIENTES WHERE clave=" & TxtCliente.Text
'RsClientes.Open "Select * From Clientes Where Clave='" & TxtCliente.Text, DBConex, adOpenStatic, adLockOptimistic
'RsClientes.Open "Select * From Clientes Where Clave='" & TxtCliente.Text & "' Order By clave", DBConex, adOpenStatic, adLockOptimistic
'With AdoCLIENTES
'.RecordSource = STRQUERY
'.Refresh
'End With
'Else
'End If
Exit Sub
error:
MsgBox Err.Description
End Sub
Private Sub TxtDescripcion_KeyPress(KeyAscii As Integer)
On Error GoTo error
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
End If
Exit Sub
error:
End Sub
Private Sub TxtPrecio_KeyPress(KeyAscii As Integer)
On Error GoTo error
If KeyAscii = 13 Then
TxtSUBtotal.Text = TxtCantidad * TxtPrecio.Text
SendKeys "{tab}"
Else
End If
Exit Sub
error:
If TxtCantidad = "" Then
MsgBox "introduzca La Cantidad", vbExclamation, "Faltan llenar Campos [SysFact]"
TxtCantidad.SetFocus
Else
If TxtPrecio.Text = "" Then
MsgBox "El Campo precio esta vacio", vbExclamation, "Faltan llenar Campos [SysFact]"
TxtPrecio.SetFocus
Else
MsgBox Err.Description, vbCritical, "Error no definido"
End If
End If
End Sub
Private Sub TXTUnidad_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
End If
End Sub
Leete esto primero, ahi entenderás más o menos lo que es un recordset y los objetos de conexion, está orientado a lo que es ADO ( ActiveX Data Objects ), pero lee la parte de los conceptos, que es eplicable en muchos casos, (si no en todos)...
http://www.aspfacil.com/articulos/040401.asp
Saludos!, ojalá te sirva de algo.
me acabo de dar cuenta que no tiene que ver eso es algo de la conexion.... o del la base de datos!!!! saludos
bueno el caso que despues de todo me muestra este maldito mensaje segun ya realize todo lo delas conexiones pero no entiendo por que... segun dice es cuando intento guardar un dato en la base me dice "Acceso Denegado"
lo ago asi adoclientes.recordset.save
y como haces la conexión? a lo mejor tienes Password, o estas abriendo la BD en modo de solo lectura
o.k muchisimas gracias a todos por ahora si se pudo eso de guardar los datos... el celaya tenia razon ahora lo abro en modo de read/write y yapuedo escribir aunque aun no logro filtrar los resultados eso no he logrado entender y lograr que funcione gracias
saludosss!!!!!!!!!