Android Question I have some questions about ADP in relation to a database?

Wien.Mart

Member
Licensed User
Longtime User
I have been having issues about using ADP in a form and assigning values to the ExpDatADP (this is the name of the customview on the form).

I have some dates stored in a database (sqlite) and the format is: mm/dd/yyyy (a string)
If I use an ExpDatADP by adding a new date, there is no problem. Just touch the ExpDatADP panel and assign the dates. The problem arises when I load the values of the cursor to the ExpDatADP field. I keep getting the error: "Object should first be initialized (label)"

The debugger stops at the: If UpdateLabel Then targetLabel.Text = DateTime.Date(selectedDate)
and throws the error "Object should first be initialized (label)".
B4X:
Private Sub SelectDay(day As Int, UpdateLabel As Boolean)
    selectedDate = DateUtils.SetDate(year, month, day)
    selectedDay = day
    selectedMonth = month
    selectedYear = year
    If UpdateLabel Then targetLabel.Text = DateTime.Date(selectedDate)
End Sub

My question is, what do I need to initialize and where? I have initialized the ExtDatADP as a customview and declared it in the sub global of the form.
 

devlei

Active Member
Licensed User
Longtime User
Ticks to Date - something like this:
B4X:
DateTime.DateFormat = "mm/dd/yyyy"
strDate = DateTime.Date(lnTicks)
 
Upvote 0

Wien.Mart

Member
Licensed User
Longtime User
Dear Giga, Devlei and All,

I still cannot assign to an ADP without getting any error. I am getting stuck with this problem, I hope you can help me. I attached the project in a zip file for your reference. In the ProfileHoH module I marked the area with the following for easier search.

'####################################################
'this is the part where i need help ... i cannot seem
'to pass the date value to the ExpDatADP ... i keep
'getting the error label need to be initialized
'my question is where? i looked at the original ADP
'sample from Erel, there is no declaration of a label
' or is there? Please help me
'####################################################

Any help or point in the right direction is highly appreciated. Thanks in advance.

Martin
 

Attachments

  • ADP.zip
    176.8 KB · Views: 164
Upvote 0

Wien.Mart

Member
Licensed User
Longtime User
To describe the error further, if I uncomment the ExpDatADP in the ProfileHoH module, I get an error. For now I commented so the program runs but I cannot assign the date value from the cursor without getting an error. The anotherdatepicker works but is left blank. I want to be able to assign the cursor value to the ExpDatADP much like all the other fields on the form.
 
Upvote 0

Wien.Mart

Member
Licensed User
Longtime User
Dear Erel,

Sorry, my bad. I reattached the zip file.

Thanks,

Martin
 

Attachments

  • ADP.zip
    176.7 KB · Views: 168
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think that I know what causes this error. If you look in ADP code you will see that it uses CallSubDelayed to build itself.

This means that it is not immediately ready. Try this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("fprofilehoh")
   btnSave.Color=Colors.LightGray
   txtID = FindHH.txtID
   If FirstTime Then
     sql1.Initialize(DBFilePath, DBFileName, True)
   End If

   CallSubDelayed(Me, "AfterCreate")
End Sub

Sub AfterCreate
   fProfLd
   spIDTypLd
   spMemCatLd
   spHHCatLd
End Sub
 
Upvote 0
Top