galera..sou novo em vba..e estou encontrando um pouco de dificuldade no access e no excel, no que diz respeito a essa linguagem de programação.
preciso importar muitos arquivos txt para o access sem perder a informação do último até então já importado. E preciso que ele seja organizado em colunas de acordo com os campos que eu selecionar logo mais. Vejamos um exemplo, pra poder ilustrar melhor o q eu precisava:
**SEGUE ABAIXO O MODELO EXATO DO TXT QUE EU DEVO IMPORTAR**
CDR 1 --> PRECISO QUE FUNCIONE COMO CHAVE PRIMARIA
csn = 2184242446
net_type = fixed network bill
bill_type = Detailed ticket
partial_record_indicator = single record
clock_indicator = No
free_indicator = charging
call_attempt_indicator = free call attempt
complain_indicator = no complaint
cama_indicator = non-centralized charging
is_credit_indicator = non-credit call
Caller_VPN_indicator = caller is not VPN user
charge_party_indicator = charging incoming trunk
start_time = 2010-10-20 09:56:21
conversation_time(10ms) = 3015
end_time = 2010-10-20 09:56:52
caller_dnset = 11
caller_address_nature = national valid number
caller_number = 1152137800
called_dnset = 11
called_address_nature = national valid number
called_number = 1140044828
centrex_group_number = 65535
caller_ctx_number = -
called_ctx_number = -
trunk_group_in = 150
trunk_group_out = 120
caller_device_type = DID_ISUP
called_device_type = DID_ISUP
caller_category = Subscriber
call_type = tandem
Service_Type = national toll
termination_code = NORMAL_CALL_CLEAR
Release_party = peer caller release
CallerSrc = 511
CalledSrc = 120
called_category = Undefined
supplementary_service_type = NEW SERVICE BUTT
charging_case = 0
pulse_count = 1
connected_dnset = 11
connected_address_nature = subscriber number
connected_number = 40044828
charge_dnset = 65535
charge_address_nature = reserved
charge_number = -
bearer_service = circuit,bearer 3.1KHZ voice
dialed_number = 40044828
release_index = 65535
partial_counter = 1
Module_number = 22
Local_csn = 89249
Service_key = 4294967295
FDS = 1
Class = 10
Caller trunk CIC = 3313
Called trunk CIC = 2154
connect_flag = connected
Query_SHLR_Fail_flag = No
route_number = 62
sub_route_number = 120
Incoming_route_identify = 150
Outgoing_route_identify = 120
CLI_rec_flux_H = 00000000
CLI_rec_flux_L = 00000000
CLI_snt_flux_H = 00000000
CLI_snt_flux_L = 00000000
CLD_rec_flux_H = 00000000
CLD_rec_flux_L = 00000000
CLD_snt_flux_H = 00000000
CLD_snt_flux_L = 00000000
CallerGK_or_SoftX3000 = 10.225.11.4
CallerGW_or_Terminal = 10.225.11.5
CalleeGK_or_SoftX3000 = 10.225.11.4
CalleeGW_or_Terminal = 255.255.255.255
caller_Roam_IP = 255.255.255.255
called_Roam_IP = 255.255.255.255
caller_Roam_Mode = unknown
called_Roam_Mode = unknown
caller_local_dnset_before_change = 0
caller_address_nature_before_change = national valid number
caller_number_before_change = 1152137800
callee_local_dnset_before_change = 0
callee_address_nature_before_change = subscriber number
EU PRECISO SOMENTE DAS LINHAS DO TXT QUE ESTAO SUBLINHADAS E EM NEGRITO! A PARTE ANTES DO SÍMBOLO DO IGUAL (=) FAZENDO PARTE DO CABEÇALHO DA TABELA DO ACCESS (TABELA já CRIADA POR MIM, NO MODO DESIGN) E A PARTE COM NUMERO OCUPANDO CADA LINHA DESSA TABELA, TENDO CADA CDR COMO CHAVE PRIMARIA DE UMA LINHA. ISSO TUDO IMPORTANDO VARIOS TXT SEM PERDER NENHUMA INFORMAÇÃO.
SERA Q ALGUÉM PODERIA ME AJUDAR?? É URGENTE E TÁ MUITO COMPLICADO!
DESDE JÁ EU AGRADEÇO A AJUDA DE TODOS.
**DEPOIS DE VÁRIAS TENTATIVAS CHEGUEI A UM CODIGO VBA, E MAIS ABAIXO O ERRO Q ELE EXECUTA**
Option Compare Database
Private Sub Comando9_Click()
Dim F As Long, sLine As String
Dim db As Database, rs As Recordset
On Error GoTo trata_erro
F = FreeFile
Open inserir_txt.Text For Input As F 'abre o arquivo texto
Set db = DBEngine(0).OpenDatabase(importar.Text) 'abre o banco de dados
On Error Resume Next 'se a tabela não existir não roda mensagem de erro
For CONTPAG = 1 To 1000 Step 1
db.Execute "DROP TABLE CDRHUAWEI" 'exclui a tabela se ela já existir
On Error GoTo trata_erro 'ativa tratamento de erros
db.Execute "CREATE TABLE CDRHUAWEI (CDR LONG, START TIME LONG, CONVERSATION TIME (10 MS) LONG, END TIME LONG, CALLER DNSET LONG, CALLER NUMBER LONG, CALLED DNSET LONG, CALLED NUMBER LONG, TRUNK GROUP IN LONG, TRUNK GROUP OUT LONG, [TERMINATION CODE] TEXT (25), FDS LONG, CLASS LONG, CALLER TRUNK CIC LONG, CALLED TRUNK CIC LONG, ROUTE NUMBER LONG, INCOMING ROUTE IDENTIFY LONG, OUTGOING ROUTE IDENTIFY LONG, CALLER NUMBER BEFORE CHANGE LONG, CALLED NUMBER BEFORE CHANGE LONG, [OPC] TEXT (15), [DPC] TEXT (15), [iNCOMING ROUTE ID] TEXT (20), [OUTGOING ROUTE ID] TEXT (20))"
'cria a tabela com suas estruturas
Next CONTPAG
Set rs = db.OpenRecordset("CDRHUAWEI", dbOpenTable) 'abre a tabela para receber os dados
Do While Not EOF(F)
Line Input #F, sLine 'lê uma linha do arquivo texto
'extrai a informação do arquivo texto
cdr = Mid(sLine, 5)
start_time = Mid(sLine, 49)
conversation_time = Mid(sLine, 49)
end_time = Mid(sLine, 49)
caller_dnset = Mid(sLine, 49)
caller_number = Mid(sLine, 49)
called_dnset = Mid(sLine, 49)
called_number = Mid(sLine, 49)
trunk_group_in = Mid(sLine, 49)
trunk_group_out = Mid(sLine, 49)
termination_code = Mid(sLine, 49)
fds = Mid(sLine, 49)
class_number = Mid(sLine, 49)
caller_trunk_cic = Mid(sLine, 49)
called_trunk_cic = Mid(sLine, 49)
route_number = Mid(sLine, 49)
incoming_route_identify = Mid(sLine, 49)
outgoing_route_identify = Mid(sLine, 49)
caller_number_before_change = Mid(sLine, 49)
called_number_before_change = Mid(sLine, 49)
opc = Mid(sLine, 49)
dpc = Mid(sLine, 49)
incoming_route_id = Mid(sLine, 49)
outgoing_route_id = Mid(sLine, 49)
rs.AddNew 'inclui novo registro
rs(0) = cdr
rs(1) = start_time
rs(2) = conversation_time
rs(3) = end_time
rs(4) = caller_dnset
rs(5) = caller_number
rs(6) = called_dnset
rs(7) = called_number
rs(8) = trunk_group_in
rs(9) = trunk_group_out
rs(10) = termination_code
rs(11) = fds
rs(12) = class_number
rs(13) = caller_trunk_cic
rs(14) = called_trunk_cic
rs(15) = route_number
rs(16) = incoming_route_identify
rs(17) = outgoing_route_identify
rs(18) = caller_number_before_change
rs(19) = called_number_before_change
rs(20) = opc
rs(21) = dpc
rs(22) = incoming_route_id
rs(23) = outgoing_route_id
rs.Update 'grava o registro inserido
Loop
MsgBox "Arquivo texto importado com sucesso !! "
rs.Close
db.Close
Close #F
Exit Sub
trata_erro:
MsgBox "Ocorreu o erro ==> " & Err.Description
End Sub
ERRO:
VOCÊ NÃO PODE FAZER REFERENCIA A UMA PROPRIEDADE OU A UM METODO DE UM CONTROLE, A MENOS QUE O CONTROLE TENHA UM FOCO.
alguém SABE ONDE EU ESTOU ERRANDO? PRECISO MTU D AJUDA
Pergunta
thur
galera..sou novo em vba..e estou encontrando um pouco de dificuldade no access e no excel, no que diz respeito a essa linguagem de programação.
preciso importar muitos arquivos txt para o access sem perder a informação do último até então já importado. E preciso que ele seja organizado em colunas de acordo com os campos que eu selecionar logo mais. Vejamos um exemplo, pra poder ilustrar melhor o q eu precisava:
**SEGUE ABAIXO O MODELO EXATO DO TXT QUE EU DEVO IMPORTAR**
CDR 1 --> PRECISO QUE FUNCIONE COMO CHAVE PRIMARIA
csn = 2184242446
net_type = fixed network bill
bill_type = Detailed ticket
partial_record_indicator = single record
clock_indicator = No
free_indicator = charging
call_attempt_indicator = free call attempt
complain_indicator = no complaint
cama_indicator = non-centralized charging
is_credit_indicator = non-credit call
Caller_VPN_indicator = caller is not VPN user
charge_party_indicator = charging incoming trunk
start_time = 2010-10-20 09:56:21
conversation_time(10ms) = 3015
end_time = 2010-10-20 09:56:52
caller_dnset = 11
caller_address_nature = national valid number
caller_number = 1152137800
called_dnset = 11
called_address_nature = national valid number
called_number = 1140044828
centrex_group_number = 65535
caller_ctx_number = -
called_ctx_number = -
trunk_group_in = 150
trunk_group_out = 120
caller_device_type = DID_ISUP
called_device_type = DID_ISUP
caller_category = Subscriber
call_type = tandem
Service_Type = national toll
termination_code = NORMAL_CALL_CLEAR
Release_party = peer caller release
CallerSrc = 511
CalledSrc = 120
called_category = Undefined
supplementary_service_type = NEW SERVICE BUTT
charging_case = 0
pulse_count = 1
connected_dnset = 11
connected_address_nature = subscriber number
connected_number = 40044828
charge_dnset = 65535
charge_address_nature = reserved
charge_number = -
bearer_service = circuit,bearer 3.1KHZ voice
dialed_number = 40044828
release_index = 65535
partial_counter = 1
Module_number = 22
Local_csn = 89249
Service_key = 4294967295
FDS = 1
Class = 10
Caller trunk CIC = 3313
Called trunk CIC = 2154
connect_flag = connected
Query_SHLR_Fail_flag = No
route_number = 62
sub_route_number = 120
Incoming_route_identify = 150
Outgoing_route_identify = 120
CLI_rec_flux_H = 00000000
CLI_rec_flux_L = 00000000
CLI_snt_flux_H = 00000000
CLI_snt_flux_L = 00000000
CLD_rec_flux_H = 00000000
CLD_rec_flux_L = 00000000
CLD_snt_flux_H = 00000000
CLD_snt_flux_L = 00000000
CallerGK_or_SoftX3000 = 10.225.11.4
CallerGW_or_Terminal = 10.225.11.5
CalleeGK_or_SoftX3000 = 10.225.11.4
CalleeGW_or_Terminal = 255.255.255.255
caller_Roam_IP = 255.255.255.255
called_Roam_IP = 255.255.255.255
caller_Roam_Mode = unknown
called_Roam_Mode = unknown
caller_local_dnset_before_change = 0
caller_address_nature_before_change = national valid number
caller_number_before_change = 1152137800
callee_local_dnset_before_change = 0
callee_address_nature_before_change = subscriber number
called_number_before_change = 40044828
ingress_MG_ID = -
egress_MG_ID = -
caller_seize_duration = 4294967295
called_seize_duration = 4294967295
OPC = 00000C1C
DPC = 000000BC
TMG_Circuits_seizure_time = -
TMG_Circuits_release_time = -
Start_Date_and_Time_of_Call_Setup = -
call_setup_duration = 4294967295
Incoming_Route_ID = LC00VMA50VMASP
Outgoing_Route_ID = 2E01SPO_00188L
Local switch name = -
local_Time_Zone = 255
CAC = -
PayerShortNumber = -
balance = 0
Ingress_Media_Gateway_TimeZone = 255
Ingress_Occupied_Time_Slot = 255
Egress_Media_Gateway_TimeZone = 255
Egress_Occupied_Time_Slot = 255
Caller_Time_Zone = 255
Called_Time_Zone = 255
caller_port_number = 4305
called_port_number = 9482
Outgoing_Traffic_Dispersion_ID = -
Incoming_Traffic_Dispersion_ID = -
Calling_SS_during_the_call = 00 00 00 00 00 00 00
teleservice = unknown
UUS1_count = 0
UUS2_count = 0
UUS3_count = 0
post_delay_metering = 613
Packetization_time(ms) = 255
Connected_data_rate = -
Packet_loss = -
PSTN_ISDN_indicator = -
ISUP_charge_number_indicator = Caller number
Connected_number_type = no forwarded
ISDN_capability = Reserved
Time_restricted_flag = no
IN_flag = NO
np_call_flag = non-NP call
charging_method = Detailed ticket
incomplete_call_watch_type = No watch
caller_ISDN_access = Terminal access non ISDN
called_ISDN_access = Terminal access non ISDN
ISUP_indication = ISUP not all way
B_num = 1
Caller_CLIR_flag = FALSE
CNG = No
Billed_party = DDD,DDI, local Calls
Service_ID = unknown
MCE = NULL
IP_release_cause = -
Caller_equipment_type = UMG
org_called_dnset = 65535
org_called_address_nature = unknown
org_number = -
redirecting_dnset = 65535
redirecting_address_nature = unknown
redirecting_number = -
SHLR_MON_Route = -
SHLR_MON_Operation = -
caller_WLL_user_type = unknow WLL user
callee_WLL_user_type = unknow WLL user
caller_WLL_home_area_information = FF FF FF FF FF
caller_WLL_visit_area_information = FF FF FF FF FF
Callee_WLL_home_area_information = FF FF FF FF FF
callee_WLL_visit_area_information = FF FF FF FF FF
IN_CallID = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Originating Line Info = InvalidValue
alerting_time = -
local_dnset_of_caller_physical_number = 65535
address_nature_of_caller_physical_number = unknown
caller_physical_number = -
local_dnset_of_callee_physical_number = 65535
address_nature_of_callee_physical_number = unknown
callee_physical_number = -
local_dnset_redirecting_physical_num = 65535
address_nature_redirecting_physical_num = unknown
redirecting_physical_number = -
local_dnset_MON_caller_physical_num = 65535
address_nature_MON_caller_physical_num = unknown
MON_caller_physical_number = -
local_dnset_MON_callee_physical_num = 65535
address_nature_MON_callee_physical_number = unknown
MON_callee_physical_number = -
caller_module = 0
called_module = 0
Bear_Mode = Non Standard
audio_codec_type = no indication
video_codec_type = no indication
Conference_ID = 00000000
Acoustic_Echo_Cancellation = no enhanced
NC = no enhanced
NR = no enhanced
Automatic_Gain_Control = no enhanced
rate = 0.0000000000
fee = 0.0000000000
service_indicator = -
caller_call_id = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
called_call_id = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--------------------------------------------------
CDR 2
csn = 2184242449
net_type = fixed network bill
bill_type = Detailed ticket
partial_record_indicator = single record
clock_indicator = No
free_indicator = free of charge
call_attempt_indicator = free call attempt
complain_indicator = no complaint
cama_indicator = non-centralized charging
is_credit_indicator = non-credit call
Caller_VPN_indicator = caller is not VPN user
charge_party_indicator = charging incoming trunk
start_time = 2010-10-20 09:56:46
conversation_time(10ms) = 536
end_time = 2010-10-20 09:56:52
caller_dnset = 11
caller_address_nature = national valid number
caller_number = 1148331700
called_dnset = 11
called_address_nature = national valid number
called_number = 311691217249
centrex_group_number = 65535
caller_ctx_number = -
called_ctx_number = -
trunk_group_in = 150
trunk_group_out = 55
caller_device_type = DID_ISUP
called_device_type = DID_ISUP
caller_category = Subscriber
call_type = tandem
Service_Type = national toll
termination_code = NORMAL
Release_party = peer called release
CallerSrc = 511
CalledSrc = 55
called_category = Undefined
supplementary_service_type = NEW SERVICE BUTT
charging_case = 0
pulse_count = 1
connected_dnset = 11
connected_address_nature = national valid number
connected_number = -
charge_dnset = 65535
charge_address_nature = reserved
charge_number = -
bearer_service = circuit,bearer 3.1KHZ voice
dialed_number = 0311691217249
release_index = 64768
partial_counter = 1
Module_number = 22
Local_csn = 89252
Service_key = 1
FDS = 5
Class = 10
Caller trunk CIC = 461
Called trunk CIC = 1434
connect_flag = connected
Query_SHLR_Fail_flag = No
route_number = 8
sub_route_number = 55
Incoming_route_identify = 150
Outgoing_route_identify = 55
CLI_rec_flux_H = 00000000
CLI_rec_flux_L = 00000000
CLI_snt_flux_H = 00000000
CLI_snt_flux_L = 00000000
CLD_rec_flux_H = 00000000
CLD_rec_flux_L = 00000000
CLD_snt_flux_H = 00000000
CLD_snt_flux_L = 00000000
CallerGK_or_SoftX3000 = 10.225.11.4
CallerGW_or_Terminal = 255.255.255.255
CalleeGK_or_SoftX3000 = 10.225.11.4
CalleeGW_or_Terminal = 255.255.255.255
caller_Roam_IP = 255.255.255.255
called_Roam_IP = 255.255.255.255
caller_Roam_Mode = unknown
called_Roam_Mode = unknown
caller_local_dnset_before_change = 0
caller_address_nature_before_change = national valid number
caller_number_before_change = 1148331700
callee_local_dnset_before_change = 0
callee_address_nature_before_change = national valid number
called_number_before_change = 0311691217249
ingress_MG_ID = -
egress_MG_ID = -
caller_seize_duration = 4294967295
called_seize_duration = 4294967295
OPC = 00000C1C
DPC = 00000F8A
TMG_Circuits_seizure_time = -
TMG_Circuits_release_time = -
Start_Date_and_Time_of_Call_Setup = -
call_setup_duration = 4294967295
Incoming_Route_ID = LC00VMA50VMASP
Outgoing_Route_ID = 0T03SPO_03978U
Local switch name = -
local_Time_Zone = 255
CAC = -
PayerShortNumber = -
balance = 0
Ingress_Media_Gateway_TimeZone = 255
Ingress_Occupied_Time_Slot = 255
Egress_Media_Gateway_TimeZone = 255
Egress_Occupied_Time_Slot = 255
Caller_Time_Zone = 255
Called_Time_Zone = 255
caller_port_number = 9357
called_port_number = 3258
Outgoing_Traffic_Dispersion_ID = -
Incoming_Traffic_Dispersion_ID = -
Calling_SS_during_the_call = 00 00 00 00 00 00 00
teleservice = unknown
UUS1_count = 0
UUS2_count = 0
UUS3_count = 0
post_delay_metering = 114
Packetization_time(ms) = 255
Connected_data_rate = -
Packet_loss = -
PSTN_ISDN_indicator = -
ISUP_charge_number_indicator = Caller number
Connected_number_type = no forwarded
ISDN_capability = Reserved
Time_restricted_flag = no
IN_flag = NO
np_call_flag = non-NP call
charging_method = Detailed ticket
incomplete_call_watch_type = No watch
caller_ISDN_access = Terminal access is ISDN
called_ISDN_access = Terminal access non ISDN
ISUP_indication = ISUP not all way
B_num = 1
Caller_CLIR_flag = FALSE
CNG = No
Billed_party = No billed calls
Service_ID = Brasil WL Service
MCE = NULL
IP_release_cause = -
Caller_equipment_type = UMG
org_called_dnset = 65535
org_called_address_nature = unknown
org_number = -
redirecting_dnset = 65535
redirecting_address_nature = unknown
redirecting_number = -
SHLR_MON_Route = -
SHLR_MON_Operation = -
caller_WLL_user_type = unknow WLL user
callee_WLL_user_type = unknow WLL user
caller_WLL_home_area_information = FF FF FF FF FF
caller_WLL_visit_area_information = FF FF FF FF FF
Callee_WLL_home_area_information = FF FF FF FF FF
callee_WLL_visit_area_information = FF FF FF FF FF
IN_CallID = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Originating Line Info = InvalidValue
alerting_time = -
local_dnset_of_caller_physical_number = 65535
address_nature_of_caller_physical_number = unknown
caller_physical_number = -
local_dnset_of_callee_physical_number = 65535
address_nature_of_callee_physical_number = unknown
callee_physical_number = -
local_dnset_redirecting_physical_num = 65535
address_nature_redirecting_physical_num = unknown
redirecting_physical_number = -
local_dnset_MON_caller_physical_num = 65535
address_nature_MON_caller_physical_num = unknown
MON_caller_physical_number = -
local_dnset_MON_callee_physical_num = 65535
address_nature_MON_callee_physical_number = unknown
MON_callee_physical_number = -
caller_module = 0
called_module = 0
Bear_Mode = Non Standard
audio_codec_type = no indication
video_codec_type = no indication
Conference_ID = 00000000
Acoustic_Echo_Cancellation = no enhanced
NC = no enhanced
NR = no enhanced
Automatic_Gain_Control = no enhanced
rate = 0.0000000000
fee = 0.0000000000
service_indicator = -
caller_call_id = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
called_call_id = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--------------------------------------------------
EU PRECISO SOMENTE DAS LINHAS DO TXT QUE ESTAO SUBLINHADAS E EM NEGRITO! A PARTE ANTES DO SÍMBOLO DO IGUAL (=) FAZENDO PARTE DO CABEÇALHO DA TABELA DO ACCESS (TABELA já CRIADA POR MIM, NO MODO DESIGN) E A PARTE COM NUMERO OCUPANDO CADA LINHA DESSA TABELA, TENDO CADA CDR COMO CHAVE PRIMARIA DE UMA LINHA. ISSO TUDO IMPORTANDO VARIOS TXT SEM PERDER NENHUMA INFORMAÇÃO.
SERA Q ALGUÉM PODERIA ME AJUDAR?? É URGENTE E TÁ MUITO COMPLICADO!
DESDE JÁ EU AGRADEÇO A AJUDA DE TODOS.
**DEPOIS DE VÁRIAS TENTATIVAS CHEGUEI A UM CODIGO VBA, E MAIS ABAIXO O ERRO Q ELE EXECUTA**
Option Compare Database
Private Sub Comando9_Click()
Dim F As Long, sLine As String
Dim db As Database, rs As Recordset
On Error GoTo trata_erro
F = FreeFile
Open inserir_txt.Text For Input As F 'abre o arquivo texto
Set db = DBEngine(0).OpenDatabase(importar.Text) 'abre o banco de dados
On Error Resume Next 'se a tabela não existir não roda mensagem de erro
For CONTPAG = 1 To 1000 Step 1
db.Execute "DROP TABLE CDRHUAWEI" 'exclui a tabela se ela já existir
On Error GoTo trata_erro 'ativa tratamento de erros
db.Execute "CREATE TABLE CDRHUAWEI (CDR LONG, START TIME LONG, CONVERSATION TIME (10 MS) LONG, END TIME LONG, CALLER DNSET LONG, CALLER NUMBER LONG, CALLED DNSET LONG, CALLED NUMBER LONG, TRUNK GROUP IN LONG, TRUNK GROUP OUT LONG, [TERMINATION CODE] TEXT (25), FDS LONG, CLASS LONG, CALLER TRUNK CIC LONG, CALLED TRUNK CIC LONG, ROUTE NUMBER LONG, INCOMING ROUTE IDENTIFY LONG, OUTGOING ROUTE IDENTIFY LONG, CALLER NUMBER BEFORE CHANGE LONG, CALLED NUMBER BEFORE CHANGE LONG, [OPC] TEXT (15), [DPC] TEXT (15), [iNCOMING ROUTE ID] TEXT (20), [OUTGOING ROUTE ID] TEXT (20))"
'cria a tabela com suas estruturas
Next CONTPAG
Set rs = db.OpenRecordset("CDRHUAWEI", dbOpenTable) 'abre a tabela para receber os dados
Do While Not EOF(F)
Line Input #F, sLine 'lê uma linha do arquivo texto
'extrai a informação do arquivo texto
cdr = Mid(sLine, 5)
start_time = Mid(sLine, 49)
conversation_time = Mid(sLine, 49)
end_time = Mid(sLine, 49)
caller_dnset = Mid(sLine, 49)
caller_number = Mid(sLine, 49)
called_dnset = Mid(sLine, 49)
called_number = Mid(sLine, 49)
trunk_group_in = Mid(sLine, 49)
trunk_group_out = Mid(sLine, 49)
termination_code = Mid(sLine, 49)
fds = Mid(sLine, 49)
class_number = Mid(sLine, 49)
caller_trunk_cic = Mid(sLine, 49)
called_trunk_cic = Mid(sLine, 49)
route_number = Mid(sLine, 49)
incoming_route_identify = Mid(sLine, 49)
outgoing_route_identify = Mid(sLine, 49)
caller_number_before_change = Mid(sLine, 49)
called_number_before_change = Mid(sLine, 49)
opc = Mid(sLine, 49)
dpc = Mid(sLine, 49)
incoming_route_id = Mid(sLine, 49)
outgoing_route_id = Mid(sLine, 49)
rs.AddNew 'inclui novo registro
rs(0) = cdr
rs(1) = start_time
rs(2) = conversation_time
rs(3) = end_time
rs(4) = caller_dnset
rs(5) = caller_number
rs(6) = called_dnset
rs(7) = called_number
rs(8) = trunk_group_in
rs(9) = trunk_group_out
rs(10) = termination_code
rs(11) = fds
rs(12) = class_number
rs(13) = caller_trunk_cic
rs(14) = called_trunk_cic
rs(15) = route_number
rs(16) = incoming_route_identify
rs(17) = outgoing_route_identify
rs(18) = caller_number_before_change
rs(19) = called_number_before_change
rs(20) = opc
rs(21) = dpc
rs(22) = incoming_route_id
rs(23) = outgoing_route_id
rs.Update 'grava o registro inserido
Loop
MsgBox "Arquivo texto importado com sucesso !! "
rs.Close
db.Close
Close #F
Exit Sub
trata_erro:
MsgBox "Ocorreu o erro ==> " & Err.Description
End Sub
ERRO:
VOCÊ NÃO PODE FAZER REFERENCIA A UMA PROPRIEDADE OU A UM METODO DE UM CONTROLE, A MENOS QUE O CONTROLE TENHA UM FOCO.
alguém SABE ONDE EU ESTOU ERRANDO? PRECISO MTU D AJUDA
OBRIGADO
Editado por thurLink para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.